Skip to content

Commit

Permalink
fix ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
kdziedzic68 committed Oct 30, 2024
1 parent 3c7f554 commit 6b80a67
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,17 @@ def id(self) -> str:
"""
return self.source.id

def add_location_metadata(self, provider_metadata: dict | None) -> None:
def add_location_metadata(self, provider_metadata: dict) -> None:
"""
Add metadata retrived by provider to document metadata.
Args:
provider_metadata: metadata retrived by provider or null.
"""
if provider_metadata:
page_number = provider_metadata.get("page_number", None)
coordinates = provider_metadata.get("coordinates", None)
self.location = DocumentLocation(page_number=page_number, coordinates=coordinates)
page_number = provider_metadata.get("page_number")
coordinates = provider_metadata.get("coordinates")
self.location = DocumentLocation(page_number=page_number, coordinates=coordinates)

async def fetch(self) -> "Document":
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from io import BytesIO
import os
from copy import deepcopy
from pathlib import Path

from unstructured.chunking.basic import chunk_elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def to_text_element(element: UnstructuredElement, document_meta: DocumentMeta) -
Returns:
text element
"""
if element.metadata:
document_meta.add_location_metadata(provider_metadata=element.metadata.to_dict())
return TextElement(
document_meta=document_meta,
content=element.text,
Expand Down

0 comments on commit 6b80a67

Please sign in to comment.