Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def __init__(
DocumentIntelligenceFileType.BMP,
DocumentIntelligenceFileType.TIFF,
],
enable_formulas: bool = True,
):
"""
Initialize the DocumentIntelligenceConverter.
Expand All @@ -154,7 +155,9 @@ def __init__(
endpoint (str): The endpoint for the Document Intelligence service.
api_version (str): The API version to use. Defaults to "2024-07-31-preview".
credential (AzureKeyCredential | TokenCredential | None): The credential to use for authentication.
file_types (List[DocumentIntelligenceFileType]): The file types to accept. Defaults to all supported file types.
file_types (List[DocumentIntelligenceFileType]): The file types to accept. Defaults to all supported types.
enable_formulas (bool): Whether to enable formula extraction. Defaults to True for backward compatibility.
Set to False to improve accuracy on documents without mathematical formulas.
"""

super().__init__()
Expand All @@ -180,6 +183,7 @@ def __init__(

self.endpoint = endpoint
self.api_version = api_version
self._enable_formulas = enable_formulas
self.doc_intel_client = DocumentIntelligenceClient(
endpoint=self.endpoint,
api_version=self.api_version,
Expand Down Expand Up @@ -228,11 +232,13 @@ def _analysis_features(self, stream_info: StreamInfo) -> List[str]:
if mimetype.startswith(prefix):
return []

return [
DocumentAnalysisFeature.FORMULAS, # enable formula extraction
features = [
DocumentAnalysisFeature.OCR_HIGH_RESOLUTION, # enable high resolution OCR
DocumentAnalysisFeature.STYLE_FONT, # enable font style extraction
]
if self._enable_formulas:
features.append(DocumentAnalysisFeature.FORMULAS)
return features

def convert(
self,
Expand Down