Skip to content

Commit

Permalink
Change default and remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
plutasnyy committed Nov 7, 2024
1 parent 7bcc6c0 commit 4a9be2c
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions unstructured/documents/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ElementTypeEnum(str, Enum):


class OntologyElement(BaseModel):
text: Optional[str] = Field(None, description="Text content of the element")
text: Optional[str] = Field("", description="Text content of the element")
css_class_name: Optional[str] = Field(
default_factory=lambda: "", description="CSS class associated with the element"
)
Expand Down Expand Up @@ -453,15 +453,6 @@ class Form(OntologyElement):
elementType: ElementTypeEnum = Field(ElementTypeEnum.form, frozen=True)
allowed_tags: List[str] = Field(["form"], frozen=True)

def to_text(self, add_children=True) -> str:
texts = [self.text] if self.text else []

if add_children:
for child in self.children:
texts.append(child.to_text(add_children=True))

return " ".join(filter(None, texts)).strip()


class FormField(OntologyElement):
description: str = Field("A property value of a form", frozen=True)
Expand Down

0 comments on commit 4a9be2c

Please sign in to comment.