5
5
import os
6
6
import time
7
7
import json
8
- from typing import Dict , List , Optional , Union
8
+ from typing import Dict
9
9
10
10
from .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
16
12
17
13
18
14
class Axiomatic (BaseClient ):
@@ -23,71 +19,6 @@ def __init__(self, *args, **kwargs):
23
19
24
20
self .document_helper = DocumentHelper (self )
25
21
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
91
22
92
23
93
24
class DocumentHelper :
0 commit comments