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

Migrate ocrd v3 #216

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open

Migrate ocrd v3 #216

wants to merge 33 commits into from

Conversation

bertsky
Copy link
Collaborator

@bertsky bertsky commented Jul 6, 2024

Depends on OCR-D/core#1240 (i.e. ocrd>=3.0).

- separate `setup` / `_init` from processing
  - inherit/override `_init`
  - init Tesseract API once, keep as class attribute
- define `process_page_pcgts` instead of `process`:
  - no input file loop
  - no METS action - just return tuples for derived images
- move shared utility functions into `common` module
- generate etree mapping by exporting PAGE model

def process(self):
def process_page_pcgts(self, pcgts, output_file_id=None, page_id=None):
Copy link
Member

@kba kba Aug 11, 2024

Choose a reason for hiding this comment

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

Besides missing the typing, this has a different signature, pcgts is not variadic here. Python allows this and it is convenient but I am wondering whether it would be better to be consistent with the typing and signature?

Suggested change
def process_page_pcgts(self, pcgts, output_file_id=None, page_id=None):
def process_page_pcgts(self, *input_pcgts, output_file_id : Optional[str] = None, page_id : Optional[str] = None) -> OcrdPage:
pcgts = input_pcgts[0]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Typing – sure, I was just to lazy again.

Variadic – I thought it would be clearer like that. So we would not have to do any arity checking in the function itself – a type checker could simply detect invalid use cases which do pass multiple pages at once. But perhaps I am wrong. (Also, we already have the arity assertion in setup.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants