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

workspace_validator: allow skipping pcgtsid check #1066

Merged
merged 4 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 3 additions & 1 deletion ocrd/ocrd/cli/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ def workspace_cli(ctx, directory, mets, mets_basename, backup):
(r' \[METS_URL\]', ''))) # XXX deprecated argument
@pass_workspace
@click.option('-a', '--download', is_flag=True, help="Download all files")
@click.option('-s', '--skip', help="Tests to skip", default=[], multiple=True, type=click.Choice(['imagefilename', 'dimension', 'mets_unique_identifier', 'mets_file_group_names', 'mets_files', 'pixel_density', 'page', 'page_xsd', 'mets_xsd', 'url']))
@click.option('-s', '--skip', help="Tests to skip", default=[], multiple=True, type=click.Choice(
['imagefilename', 'dimension', 'pixel_density', 'page', 'url', 'page_xsd', 'mets_fileid_page_pcgtsid',
'mets_unique_identifier', 'mets_file_group_names', 'mets_files', 'mets_xsd']))
@click.option('--page-textequiv-consistency', '--page-strictness', help="How strict to check PAGE multi-level textequiv consistency", type=click.Choice(['strict', 'lax', 'fix', 'off']), default='strict')
@click.option('--page-coordinate-consistency', help="How fierce to check PAGE multi-level coordinate consistency", type=click.Choice(['poly', 'baseline', 'both', 'off']), default='poly')
@click.argument('mets_url', default=None, required=False)
Expand Down
11 changes: 9 additions & 2 deletions ocrd_validators/ocrd_validators/workspace_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def __init__(self, resolver, mets_url, src_dir=None, skip=None, download=False,
self.download = download
self.page_strictness = page_strictness
self.page_coordinate_consistency = page_coordinate_consistency
self.page_checks = []
# there will be more options to come
if 'mets_fileid_page_pcgtsid' not in self.skip:
self.page_checks.append('pcgtsid')

self.src_dir = src_dir
self.workspace = None
Expand All @@ -100,7 +104,10 @@ def validate(*args, **kwargs):
resolver (:class:`ocrd.Resolver`): Resolver
mets_url (string): URL of the METS file
src_dir (string, None): Directory containing mets file
skip (list): Tests to skip. One or more of 'mets_unique_identifier', 'mets_file_group_names', 'mets_files', 'pixel_density', 'dimension', 'url'
skip (list): Tests to skip. One or more of
'mets_unique_identifier', 'mets_file_group_names',
'mets_files', 'pixel_density', 'dimension', 'url',
'mets_fileid_page_pcgtsid'
download (boolean): Whether to download files

Returns:
Expand Down Expand Up @@ -292,7 +299,7 @@ def _validate_page(self):
check_coords=self.page_coordinate_consistency in ['poly', 'both'],
check_baseline=self.page_coordinate_consistency in ['baseline', 'both'])
pg = page_from_file(ocrd_file)
if pg.pcGtsId != ocrd_file.ID:
if 'pcgtsid' in self.page_checks and pg.pcGtsId != ocrd_file.ID:
page_report.add_warning('pc:PcGts/@pcGtsId differs from mets:file/@ID: "%s" !== "%s"' % (pg.pcGtsId or '', ocrd_file.ID or ''))
self.report.merge_report(page_report)

Expand Down