Skip to content

Commit beb8758

Browse files
committed
Updated lint from TR#1 updates
1 parent cf96c45 commit beb8758

4 files changed

Lines changed: 11 additions & 25 deletions

File tree

pdf-table-extraction-docling-vs-llamaparse/docling_formats.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ def main() -> None:
1313
document = converter.convert(PDF_PATH).document
1414

1515
markdown = document.export_to_markdown()
16-
Path("output_docling.md").write_text(
17-
markdown, encoding="utf-8"
18-
)
16+
Path("output_docling.md").write_text(markdown, encoding="utf-8")
1917

2018
payload = document.export_to_dict()
2119
Path("output_docling.json").write_text(
@@ -24,9 +22,7 @@ def main() -> None:
2422
)
2523

2624
html = document.export_to_html()
27-
Path("output_docling.html").write_text(
28-
html, encoding="utf-8"
29-
)
25+
Path("output_docling.html").write_text(html, encoding="utf-8")
3026

3127
for index, table in enumerate(document.tables):
3228
frame = table.export_to_dataframe(doc=document)

pdf-table-extraction-docling-vs-llamaparse/docling_tables.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,11 @@ def main() -> None:
1717
frame = table.export_to_dataframe(doc=document)
1818
print(f"Table {index}: pages {pages}, shape {frame.shape}")
1919

20-
index_table = document.tables[0].export_to_dataframe(
21-
doc=document
22-
)
20+
index_table = document.tables[0].export_to_dataframe(doc=document)
2321
print("\nFinancial statement index (table 0):")
2422
print(index_table.to_string(index=False), end="\n\n")
2523

26-
operations_table = document.tables[1].export_to_dataframe(
27-
doc=document
28-
)
24+
operations_table = document.tables[1].export_to_dataframe(doc=document)
2925
print("Operations statement preview (table 1, first 4 rows):")
3026
print(operations_table.head(4).to_string())
3127

pdf-table-extraction-docling-vs-llamaparse/llamaparse_extraction.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ def main() -> None:
2727
print(pages[:3000])
2828
print(f"Pages parsed: {len(result.markdown.pages)}")
2929

30+
3031
if __name__ == "__main__":
3132
main()

pdf-table-extraction-docling-vs-llamaparse/llamaparse_formats.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class RevenueRow(BaseModel):
2222
description="Year-over-year growth percentage if stated",
2323
)
2424

25+
2526
class RevenueTable(BaseModel):
2627
rows: list[RevenueRow] = Field(
2728
description="One row per quarter in the table"
@@ -43,21 +44,13 @@ def main() -> None:
4344
markdown_pages = "\n\n".join(
4445
page.markdown for page in parsed.markdown.pages
4546
)
46-
Path("output_llamaparse.md").write_text(
47-
markdown_pages, encoding="utf-8"
48-
)
47+
Path("output_llamaparse.md").write_text(markdown_pages, encoding="utf-8")
4948

5049
if parsed.text and parsed.text.pages:
51-
text_pages = "\n".join(
52-
page.text for page in parsed.text.pages
53-
)
54-
Path("output_llamaparse.text").write_text(
55-
text_pages, encoding="utf-8"
56-
)
57-
58-
extract_file = client.files.create(
59-
file=PDF_PATH, purpose="extract"
60-
)
50+
text_pages = "\n".join(page.text for page in parsed.text.pages)
51+
Path("output_llamaparse.text").write_text(text_pages, encoding="utf-8")
52+
53+
extract_file = client.files.create(file=PDF_PATH, purpose="extract")
6154
job = client.extract.run(
6255
file_input=extract_file.id,
6356
configuration={

0 commit comments

Comments
 (0)