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

ocrd-dummy: make copying optional and disable by default, #803 #814

Merged
merged 4 commits into from
Dec 13, 2022

Conversation

kba
Copy link
Member

@kba kba commented Mar 7, 2022

No description provided.

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.

Something is rotten in the state of Denmark.

The behaviour used to be:

  • for each input file representing a physical page (which could be PAGE-XML, a single image file or a single file of some other type),
    • if PAGE-XML, just update the pcGtsId and append to Metadata, writing a copy in the output fileGrp
    • otherwise, make a byte-by-byte copy in the output fileGrp; further, if it was an image file, create a new PAGE-XML referencing that image file as original

We were dissatisfied with that, because copying images is generally not necessary and also not typical for OCR-D. (Images are always re-referenced by new PAGE-XML. Only new images must be added – if the processor operates on images. But ocrd-dummy is not such a processor. You can use ocrd-preprocess-image for that kind of thing.)

IMHO all that was necessary was to add a parameter copy_files=false and change the non-PAGE case such that the copying is dependent on that parameter (plus the image reference filename is, because you must use the new filename iff you created a new one).

However, the new behaviour here becomes:

  • for each input file representing a physical page (which could be PAGE-XML, a single image file or a single file of some other type),
    • if PAGE-XML
      • if copy_files=true, then update the pcGtsId and append to Metadata, writing a copy in the output fileGrp
      • if copy_files=false, then do nothing (!)
    • otherwise,
      • if copy_files=true, then make a byte-by-byte copy in the output fileGrp
      • if copy_files=false, then do nothing
      • further, if it was an image file, create a new PAGE-XML referencing that image file as original (but always the old image file!)

Why would you want to do this?

@kba kba self-assigned this Dec 13, 2022
@kba
Copy link
Member Author

kba commented Dec 13, 2022

OK, I have revised the logic. Now:

  • If input file is PAGE-XML:
    • set new pcGtsId
    • write output filegroup
  • if input file is anything else except PAGE-XML
    • if copy_files=true:
      • copy input file to output filegroup, byte-by-byte
    • if input file is an image:
      • create PAGE-XML for it and reference either the original image (if copy_files=false), otherwise the copy we just created, in imageFilename.

I think that should be what you proposed and what @stefanCCS wants.

@kba
Copy link
Member Author

kba commented Dec 13, 2022

Failing CI is because macos, test passes for linux.

@kba kba merged commit 7144fec into master Dec 13, 2022
@kba kba deleted the dummy-wo-copy branch December 13, 2022 16:22
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