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

[app][fix] compare vs page _type #17

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion ocrd_page_to_alto/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def __init__(self):
def set_alto_tag_from_type(self, reg_alto, reg_page):
typ = reg_page.get_type() if hasattr(reg_page, 'get_type') else None
if typ:
if hasattr(reg_alto, 'TYPE'):
if hasattr(reg_page, 'type_'):
Copy link
Member

@kba kba Aug 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is there to prevent setting TYPE for an ALTO element that doesn't support it. That's most types, only ComposedBlock and Illustration allow it. Your check verifies that the source region in PAGE has a type_ attribute - which they all do (at least at this point in the code), so it fixes the issue for your data but produces invalid ALTO.

Have a look at #18 whether that fixes your problem as well. Feel free to share test data / conditions so we can make a regression test for this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, my intention was just to fix the red badge on the project's page.

The whitelist approach fits far better in this context, I'm fine with it

reg_alto.set('TYPE', typ)
reg_alto.set('TAGREFS', self.get_id(label=typ))