-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eccb7d2
commit 1ae8f34
Showing
6 changed files
with
79 additions
and
36 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
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
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
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 pdftext.extraction import table_output | ||
|
||
|
||
def test_table_extraction(pdf_path, pdf_doc): | ||
pages = [5] | ||
page_size = pdf_doc[5].get_size() | ||
img_size = [p * 2 for p in page_size] | ||
|
||
# Rescale to img size | ||
def rescale_table(bbox): | ||
return [ | ||
bbox[0] * img_size[0], | ||
bbox[1] * img_size[1], | ||
bbox[2] * img_size[0], | ||
bbox[3] * img_size[1] | ||
] | ||
|
||
table_inputs = [ | ||
{ | ||
"tables": [ | ||
rescale_table([0.0925, 0.116, 0.871, 0.324]), | ||
rescale_table([0.171, 0.365, 0.794, 0.492]) | ||
], | ||
"img_size": img_size | ||
} | ||
] | ||
tables = table_output(pdf_path, table_inputs, page_range=pages) | ||
assert len(tables) == 1 | ||
assert len(tables[0]) == 2 | ||
assert len(tables[0][0]) == 127 | ||
assert len(tables[0][1]) == 74 | ||
assert tables[0][0][-1]["text"].strip() == "58.45" | ||
assert tables[0][1][-1]["text"].strip() == "7.0h" |