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

implement value range with .. operator for pageId #672

Merged
merged 5 commits into from
Feb 26, 2021
Merged

Conversation

kba
Copy link
Member

@kba kba commented Feb 18, 2021

When processing works with a non-trivial amount of pages, or when a long process fails in the middle of a run, it would be useful to not only allow comma-separated page ID values but ranges of page IDs.

This PR implements this by introducing the syntax --page-id <startid>..<endid> which

  • extracts the first contiguous match of numbers of both <startid> and <endid>
  • counts from start to end number and replaces the number in with the zero-padded current number

E.g. you can do ocrd-processor -g PHYS_0001..PHYS_0003 is equivalent to ocrd-processor -g PHYS_0001,PHYS_0002,PHYS_0003 but shorter.

@kba kba requested a review from bertsky February 18, 2021 14:26
Copy link
Collaborator

@bertsky bertsky left a comment

Choose a reason for hiding this comment

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

Very nice!

(Although I would personally find it more intuitive if 01..05 included 05. Most users will probably not be programmers. And even if they are, they might expect semantics as in shell brace expansion.)

@kba
Copy link
Member Author

kba commented Feb 19, 2021

Although I would personally find it more intuitive if 01..05 included 05

That was my intention ("Generate a list of strings by incrementing the number part of start until including end.") but I got wrong how range works myself :) fixing that.

@kba
Copy link
Member Author

kba commented Feb 19, 2021

Should we also support this for --file-id?

@codecov-io
Copy link

codecov-io commented Feb 19, 2021

Codecov Report

Merging #672 (7db6083) into master (2e01120) will increase coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #672      +/-   ##
==========================================
+ Coverage   78.73%   78.82%   +0.08%     
==========================================
  Files          55       55              
  Lines        3443     3457      +14     
  Branches      698      702       +4     
==========================================
+ Hits         2711     2725      +14     
  Misses        592      592              
  Partials      140      140              
Impacted Files Coverage Δ
ocrd_utils/ocrd_utils/__init__.py 100.00% <ø> (ø)
ocrd_models/ocrd_models/ocrd_mets.py 93.21% <100.00%> (+0.15%) ⬆️
ocrd_utils/ocrd_utils/str.py 91.00% <100.00%> (+0.89%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2e01120...7db6083. Read the comment docs.

@bertsky
Copy link
Collaborator

bertsky commented Feb 19, 2021

Should we also support this for --file-id?

Not so sure. That's not part of the processor API, and you can still use the regex syntax...

BTW, the pageId range expression must go to the spec, too.

kba added a commit to OCR-D/spec that referenced this pull request Feb 19, 2021
@kba kba merged commit 0794eaa into master Feb 26, 2021
@kba kba deleted the page-id-range branch February 26, 2021 16:17
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.

3 participants