-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix issue #556 and expand table benchmarks #582
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
Open
conjuncts
wants to merge
10
commits into
datalab-to:dev
Choose a base branch
from
conjuncts:master
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
50b4b4f
Fix #556 by assigning text to figures in 2nd pass
conjuncts e2afc95
Make tests runnable on windows
conjuncts e02b40b
Add test for issue #556
conjuncts 50f737e
Merge branch 'dev' into master
conjuncts 35746f8
Fix style issues
conjuncts a6b781e
Write __exit__ for ImageProvider
conjuncts d51c53f
Allow synthtabnet as table benchmark option
conjuncts a348997
Improvements to synthtabnet benchmark
conjuncts c61a6bc
Merge branch 'dev' of https://github.com/VikParuchuri/marker
conjuncts cc0ba75
Swap arguments
conjuncts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,66 @@ | ||
| from surya.layout.schema import LayoutResult | ||
|
|
||
| from marker.builders.document import DocumentBuilder | ||
| from marker.builders.layout import LayoutBuilder | ||
| from marker.builders.line import LineBuilder | ||
| from marker.providers import ProviderOutput | ||
| import marker.schema.blocks | ||
| from marker.schema.groups.page import PageGroup | ||
| from marker.schema.polygon import PolygonBox | ||
| from tests.utils import convert_to_provider_output | ||
|
|
||
|
|
||
| def test_block_assignment(): | ||
| page_bbox = [0, 0, 500, 500] | ||
| blocks = [ | ||
| (100, 0, 200, 500, marker.schema.blocks.Figure), | ||
| (200, 0, 300, 500, marker.schema.blocks.Text) | ||
| ] | ||
| words = [ | ||
| (110, 0, 120, 10, "fig"), | ||
| (110, 10, 120, 20, "fig"), | ||
| (110, 20, 120, 30, "fig"), | ||
|
|
||
| (220, 0, 230, 10, "intext"), | ||
| (220, 10, 230, 20, "intext"), | ||
| (220, 20, 230, 30, "intext"), | ||
|
|
||
| (150, 30, 250, 40, "both"), | ||
| (150, 40, 250, 50, "both"), | ||
| (150, 50, 250, 60, "both"), | ||
|
|
||
| (180, 60, 280, 70, "mosttext"), | ||
| (180, 70, 280, 80, "mosttext"), | ||
| (180, 80, 280, 90, "mosttext"), | ||
|
|
||
| (120, 90, 220, 100, "mostfig"), | ||
| (120, 100, 220, 110, "mostfig"), | ||
| (120, 110, 220, 120, "mostfig"), | ||
| ] | ||
| block_ctr = 0 | ||
| def get_counter(): | ||
| nonlocal block_ctr | ||
| o = block_ctr | ||
| block_ctr += 1 | ||
| return o | ||
| page_group = PageGroup(polygon=PolygonBox.from_bbox(page_bbox), | ||
| children=[ | ||
| block_cls(polygon=PolygonBox.from_bbox([xmin, ymin, xmax, ymax]), | ||
| page_id=0, | ||
| block_id=get_counter()) | ||
| for xmin, ymin, xmax, ymax, block_cls in blocks | ||
| ]) | ||
|
|
||
| provider_outputs = [ | ||
| convert_to_provider_output([word], page_bbox=[0, 0, 500, 500], get_counter=get_counter) for word in words | ||
| ] | ||
|
|
||
|
|
||
| assert not page_group.children[0].structure, "figure's structure should begin with nothing in it" | ||
| assert not page_group.children[1].structure, "text's structure should begin with nothing in it" | ||
|
|
||
| page_group.merge_blocks(provider_outputs, text_extraction_method='custom') | ||
|
|
||
| assert len(page_group.children[0].structure) == 3, "figure should have just 3 words" | ||
| assert len(page_group.children[1].structure) == 12, "text should have the remaining 12 words" | ||
|
|
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.