55import os
66import time
77import json
8- from typing import Dict , List , Optional , Union
8+ from typing import Dict
99
1010from .base_client import BaseClient , AsyncBaseClient
11- from . import ParseResponse , EquationExtractionResponse , EquationProcessingResponse
12- from .axtract .axtract_report import create_report
13- from .axtract .validation_results import display_full_results
14- from .axtract .interactive_table import _create_variable_dict
15- from .types .variable_requirement import VariableRequirement as ApiVariableRequirement
11+ from .types .parse_response import ParseResponse
1612
1713
1814class Axiomatic (BaseClient ):
@@ -23,71 +19,6 @@ def __init__(self, *args, **kwargs):
2319
2420 self .document_helper = DocumentHelper (self )
2521 self .tools_helper = ToolsHelper (self )
26- self .axtract_helper = AxtractHelper (self )
27-
28-
29- class AxtractHelper :
30- from .axtract .interactive_table import VariableRequirement
31-
32- _ax_client : Axiomatic
33-
34- def __init__ (self , ax_client : Axiomatic ):
35- self ._ax_client = ax_client
36-
37- def create_report (self , response : EquationExtractionResponse , path : str ):
38- create_report (response , path )
39-
40- def analyze_equations (
41- self ,
42- file_path : Optional [str ] = None ,
43- url_path : Optional [str ] = None ,
44- parsed_paper : Optional [ParseResponse ] = None ,
45- ) -> Optional [EquationExtractionResponse ]:
46- if file_path :
47- with open (file_path , "rb" ) as pdf_file :
48- response = self ._ax_client .document .equation .from_pdf (document = pdf_file )
49-
50- elif url_path :
51- if "arxiv" in url_path and "abs" in url_path :
52- url_path = url_path .replace ("abs" , "pdf" )
53- url_file = requests .get (url_path )
54- from io import BytesIO
55- pdf_stream = BytesIO (url_file .content )
56- response = self ._ax_client .document .equation .from_pdf (document = pdf_stream )
57-
58- elif parsed_paper :
59- response = EquationExtractionResponse .model_validate (
60- self ._ax_client .document .equation .process (** parsed_paper .model_dump ()).model_dump ()
61- )
62-
63- else :
64- print ("Please provide either a file path or a URL to analyze." )
65- return None
66-
67- return response
68-
69- def validate_equations (
70- self ,
71- requirements : List [VariableRequirement ],
72- loaded_equations : EquationExtractionResponse ,
73- show_hypergraph : bool = True ,
74- ):
75- api_requirements = [
76- ApiVariableRequirement (
77- symbol = req .symbol , name = req .name , value = req .value , units = req .units , tolerance = req .tolerance
78- )
79- for req in requirements
80- ]
81-
82- variable_dict = _create_variable_dict (loaded_equations )
83- api_response = self ._ax_client .document .equation .validate (request = api_requirements )
84- display_full_results (api_response .model_dump (), variable_dict , show_hypergraph = show_hypergraph )
85-
86- def set_numerical_requirements (self , extracted_equations ):
87- from .axtract .interactive_table import interactive_table
88-
89- result = interactive_table (extracted_equations )
90- return result
9122
9223
9324class DocumentHelper :
0 commit comments