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
17 changes: 9 additions & 8 deletions unstructured/partition/html/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
ONTOLOGY_CLASS_TO_UNSTRUCTURED_ELEMENT_TYPE,
)

inline_classes = (ontology.Hyperlink,)

inline_categories = (
ontology.ElementTypeEnum.specialized_text,
ontology.ElementTypeEnum.annotation,
)

RECURSION_LIMIT = 50


Expand Down Expand Up @@ -207,16 +214,10 @@ def is_text_element(ontology_element: ontology.OntologyElement) -> bool:
def is_inline_element(ontology_element: ontology.OntologyElement) -> bool:
"""Categories or classes that we want to combine with text elements"""

inline_classes = [ontology.Hyperlink]
inline_categories = [
ontology.ElementTypeEnum.specialized_text,
ontology.ElementTypeEnum.annotation,
]

if any(isinstance(ontology_element, class_) for class_ in inline_classes):
if isinstance(ontology_element, inline_classes):
return True

return any(ontology_element.elementType == category for category in inline_categories)
return ontology_element.elementType in inline_categories


def unstructured_elements_to_ontology(
Expand Down