22import requests
33import os
44import time
5- from typing import Dict
5+ from typing import Dict , List
66
77from .base_client import BaseClient , AsyncBaseClient
88from . import ParseResponse
@@ -32,16 +32,20 @@ def create_report(self, response: EquationExtractionResponse, path: str):
3232
3333 create_report (response , path )
3434
35- def analyze_equations (self , file_path : str = None , url_path : str = None ):
35+ def analyze_equations (
36+ self ,
37+ file_path : str | None = None ,
38+ url_path : str | None = None
39+ ) -> EquationExtractionResponse | None :
3640 if file_path :
37- file = open (file_path , "rb" )
38- response = self ._ax_client .document .equation .from_pdf (document = file )
41+ with open (file_path , "rb" ) as file :
42+ response = self ._ax_client .document .equation .from_pdf (document = file )
3943
4044 elif url_path :
4145 if "arxiv" in url_path and "abs" in url_path :
4246 url_path = url_path .replace ("abs" , "pdf" )
43-
44- response = self ._ax_client .document .equation .from_pdf (document = file )
47+
48+ response = self ._ax_client .document .equation .from_pdf (url = url_path )
4549
4650 else :
4751 print ("Please provide either a file path or a URL to analyze." )
@@ -51,15 +55,15 @@ def analyze_equations(self, file_path: str = None, url_path: str = None):
5155
5256 def validate_equations (
5357 self ,
54- requirements : list [VariableRequirement ],
58+ requirements : List [VariableRequirement ],
5559 loaded_equations : EquationExtractionResponse ,
5660 show_hypergraph : bool = True ,
5761 ):
5862 from .axtract .validation_results import display_full_results
5963 from .axtract .interactive_table import _create_variable_dict
6064
6165 variable_dict = _create_variable_dict (loaded_equations )
62- api_response = self ._ax_client .document .equation .validate (request = requirements [0 ])
66+ api_response = self ._ax_client .document .equation .validate (request = [ requirements [0 ] ])
6367 display_full_results (api_response .model_dump (), variable_dict , show_hypergraph = show_hypergraph )
6468
6569 def set_numerical_requirements (self , extracted_equations ):
0 commit comments