Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: description of supported formats and backends #788

Merged
merged 4 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
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
50 changes: 25 additions & 25 deletions docling/backend/xml/uspto_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def _add_property(self, name: str, text: str) -> None:
if name == self.Element.TITLE.value:
if text:
self.parents[self.level + 1] = self.doc.add_title(
parent=self.parents[self.level], # type: ignore[arg-type]
parent=self.parents[self.level],
text=text,
)
self.level += 1
Expand All @@ -406,7 +406,7 @@ def _add_property(self, name: str, text: str) -> None:
abstract_item = self.doc.add_heading(
heading_text,
level=heading_level,
parent=self.parents[heading_level], # type: ignore[arg-type]
parent=self.parents[heading_level],
)
self.doc.add_text(
label=DocItemLabel.PARAGRAPH,
Expand Down Expand Up @@ -434,7 +434,7 @@ def _add_property(self, name: str, text: str) -> None:
claims_item = self.doc.add_heading(
heading_text,
level=heading_level,
parent=self.parents[heading_level], # type: ignore[arg-type]
parent=self.parents[heading_level],
)
for text in self.claims:
self.doc.add_text(
Expand All @@ -452,15 +452,15 @@ def _add_property(self, name: str, text: str) -> None:
self.doc.add_text(
label=DocItemLabel.PARAGRAPH,
text=text,
parent=self.parents[self.level], # type: ignore[arg-type]
parent=self.parents[self.level],
)
self.text = ""

elif name == self.Element.HEADING.value and text:
self.parents[self.level + 1] = self.doc.add_heading(
text=text,
level=self.level,
parent=self.parents[self.level], # type: ignore[arg-type]
parent=self.parents[self.level],
)
self.level += 1
self.text = ""
Expand All @@ -470,7 +470,7 @@ def _add_property(self, name: str, text: str) -> None:
empty_table = TableData(num_rows=0, num_cols=0, table_cells=[])
self.doc.add_table(
data=empty_table,
parent=self.parents[self.level], # type: ignore[arg-type]
parent=self.parents[self.level],
)

def _apply_style(self, text: str, style_tag: str) -> str:
Expand Down Expand Up @@ -721,7 +721,7 @@ def _add_property(self, name: str, text: str) -> None:
if self.Element.TITLE.value in self.property and text.strip():
title = text.strip()
self.parents[self.level + 1] = self.doc.add_title(
parent=self.parents[self.level], # type: ignore[arg-type]
parent=self.parents[self.level],
text=title,
)
self.level += 1
Expand Down Expand Up @@ -749,7 +749,7 @@ def _add_property(self, name: str, text: str) -> None:
self.parents[self.level + 1] = self.doc.add_heading(
text=text.strip(),
level=self.level,
parent=self.parents[self.level], # type: ignore[arg-type]
parent=self.parents[self.level],
)
self.level += 1

Expand All @@ -769,7 +769,7 @@ def _add_property(self, name: str, text: str) -> None:
claims_item = self.doc.add_heading(
heading_text,
level=heading_level,
parent=self.parents[heading_level], # type: ignore[arg-type]
parent=self.parents[heading_level],
)
for text in self.claims:
self.doc.add_text(
Expand All @@ -787,7 +787,7 @@ def _add_property(self, name: str, text: str) -> None:
abstract_item = self.doc.add_heading(
heading_text,
level=heading_level,
parent=self.parents[heading_level], # type: ignore[arg-type]
parent=self.parents[heading_level],
)
self.doc.add_text(
label=DocItemLabel.PARAGRAPH, text=abstract, parent=abstract_item
Expand All @@ -799,7 +799,7 @@ def _add_property(self, name: str, text: str) -> None:
self.doc.add_text(
label=DocItemLabel.PARAGRAPH,
text=paragraph,
parent=self.parents[self.level], # type: ignore[arg-type]
parent=self.parents[self.level],
)
elif self.Element.CLAIM.value in self.property:
# we may need a space after a paragraph in claim text
Expand All @@ -811,7 +811,7 @@ def _add_property(self, name: str, text: str) -> None:
empty_table = TableData(num_rows=0, num_cols=0, table_cells=[])
self.doc.add_table(
data=empty_table,
parent=self.parents[self.level], # type: ignore[arg-type]
parent=self.parents[self.level],
)

def _apply_style(self, text: str, style_tag: str) -> str:
Expand Down Expand Up @@ -938,7 +938,7 @@ def store_section(self, section: str) -> None:
self.parents[self.level + 1] = self.doc.add_heading(
heading.value,
level=self.level,
parent=self.parents[self.level], # type: ignore[arg-type]
parent=self.parents[self.level],
)
self.level += 1

Expand All @@ -959,7 +959,7 @@ def store_content(self, section: str, field: str, value: str) -> None:

if field == self.Field.TITLE.value:
self.parents[self.level + 1] = self.doc.add_title(
parent=self.parents[self.level], text=value # type: ignore[arg-type]
parent=self.parents[self.level], text=value
)
self.level += 1

Expand All @@ -971,14 +971,14 @@ def store_content(self, section: str, field: str, value: str) -> None:
self.doc.add_text(
label=DocItemLabel.PARAGRAPH,
text=value,
parent=self.parents[self.level], # type: ignore[arg-type]
parent=self.parents[self.level],
)

elif field == self.Field.NUMBER.value and section == self.Section.CLAIMS.value:
self.doc.add_text(
label=DocItemLabel.PARAGRAPH,
text="",
parent=self.parents[self.level], # type: ignore[arg-type]
parent=self.parents[self.level],
)

elif (
Expand All @@ -996,7 +996,7 @@ def store_content(self, section: str, field: str, value: str) -> None:
last_claim = self.doc.add_text(
label=DocItemLabel.PARAGRAPH,
text="",
parent=self.parents[self.level], # type: ignore[arg-type]
parent=self.parents[self.level],
)

last_claim.text += f" {value}" if last_claim.text else value
Expand All @@ -1012,7 +1012,7 @@ def store_content(self, section: str, field: str, value: str) -> None:
self.parents[self.level + 1] = self.doc.add_heading(
value,
level=self.level,
parent=self.parents[self.level], # type: ignore[arg-type]
parent=self.parents[self.level],
)
self.level += 1

Expand All @@ -1029,7 +1029,7 @@ def store_content(self, section: str, field: str, value: str) -> None:
self.doc.add_text(
label=DocItemLabel.PARAGRAPH,
text=value,
parent=self.parents[self.level], # type: ignore[arg-type]
parent=self.parents[self.level],
)

def parse(self, patent_content: str) -> Optional[DoclingDocument]:
Expand Down Expand Up @@ -1283,7 +1283,7 @@ def _add_property(self, name: str, text: str) -> None:
title = text.strip()
if title:
self.parents[self.level + 1] = self.doc.add_text(
parent=self.parents[self.level], # type: ignore[arg-type]
parent=self.parents[self.level],
label=DocItemLabel.TITLE,
text=title,
)
Expand All @@ -1301,7 +1301,7 @@ def _add_property(self, name: str, text: str) -> None:
abstract_item = self.doc.add_heading(
heading_text,
level=heading_level,
parent=self.parents[heading_level], # type: ignore[arg-type]
parent=self.parents[heading_level],
)
self.doc.add_text(
label=DocItemLabel.PARAGRAPH,
Expand Down Expand Up @@ -1331,7 +1331,7 @@ def _add_property(self, name: str, text: str) -> None:
claims_item = self.doc.add_heading(
heading_text,
level=heading_level,
parent=self.parents[heading_level], # type: ignore[arg-type]
parent=self.parents[heading_level],
)
for text in self.claims:
self.doc.add_text(
Expand All @@ -1350,14 +1350,14 @@ def _add_property(self, name: str, text: str) -> None:
self.parents[self.level + 1] = self.doc.add_heading(
text=text,
level=self.level,
parent=self.parents[self.level], # type: ignore[arg-type]
parent=self.parents[self.level],
)
self.level += 1
else:
self.doc.add_text(
label=DocItemLabel.PARAGRAPH,
text=text,
parent=self.parents[self.level], # type: ignore[arg-type]
parent=self.parents[self.level],
)
self.text = ""

Expand All @@ -1366,7 +1366,7 @@ def _add_property(self, name: str, text: str) -> None:
empty_table = TableData(num_rows=0, num_cols=0, table_cells=[])
self.doc.add_table(
data=empty_table,
parent=self.parents[self.level], # type: ignore[arg-type]
parent=self.parents[self.level],
)

def _apply_style(self, text: str, style_tag: str) -> str:
Expand Down
Loading
Loading