-
Notifications
You must be signed in to change notification settings - Fork 773
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix when parent id is none for first element in v2 notion: (#3752)
- Loading branch information
Showing
5 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
test_unstructured/partition/html/test_unstructured_elements_to_ontology_parsing.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from unstructured.documents.elements import ElementMetadata, NarrativeText, Text | ||
from unstructured.documents.ontology import Document, Page, Paragraph | ||
from unstructured.partition.html.transformations import unstructured_elements_to_ontology | ||
|
||
|
||
def test_when_first_elements_does_not_have_id(): | ||
unstructured_elements = [ | ||
Text( | ||
element_id="1", | ||
text="", | ||
metadata=ElementMetadata(text_as_html='<div class="Page" id="1"/>'), | ||
), | ||
NarrativeText( | ||
element_id="2", | ||
text="Example text", | ||
metadata=ElementMetadata( | ||
text_as_html='<p class="Paragraph" id="2"> Example text </p>', parent_id="1" | ||
), | ||
), | ||
] | ||
ontology = unstructured_elements_to_ontology(unstructured_elements) | ||
|
||
assert isinstance(ontology, Document) | ||
|
||
assert len(ontology.children) == 1 | ||
page = ontology.children[0] | ||
|
||
assert isinstance(page, Page) | ||
assert len(page.children) == 1 | ||
paragraph = page.children[0] | ||
|
||
assert isinstance(paragraph, Paragraph) | ||
assert paragraph.text == "Example text" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.16.2" # pragma: no cover | ||
__version__ = "0.16.3-dev1" # pragma: no cover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters