From 79030922b4d77378a81796374d3ec50f4ba15518 Mon Sep 17 00:00:00 2001 From: Konstantin Baierer Date: Tue, 11 Aug 2020 15:28:26 +0200 Subject: [PATCH] use make_file_id and assert_file_grp_cardinality --- .../ocrd_repair_inconsistencies.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ocrd_repair_inconsistencies/ocrd_repair_inconsistencies.py b/ocrd_repair_inconsistencies/ocrd_repair_inconsistencies.py index 82500aa..9722f8b 100644 --- a/ocrd_repair_inconsistencies/ocrd_repair_inconsistencies.py +++ b/ocrd_repair_inconsistencies/ocrd_repair_inconsistencies.py @@ -11,7 +11,9 @@ from ocrd_models.ocrd_page import ( to_xml ) from ocrd_utils import ( - getLogger, concat_padded, + assert_file_grp_cardinality, + getLogger, + make_file_id, polygon_from_points, MIMETYPE_PAGE ) @@ -30,6 +32,9 @@ class RepairInconsistencies(Processor): super(RepairInconsistencies, self).__init__(*args, **kwargs) def process(self): + assert_file_grp_cardinality(self.input_file_grp, 1) + assert_file_grp_cardinality(self.output_file_grp, 1) + for (n, input_file) in enumerate(self.input_files): page_id = input_file.pageId or input_file.ID LOG.info("INPUT FILE %i / %s", n, page_id) @@ -101,9 +106,7 @@ class RepairInconsistencies(Processor): _fix_segment(word, page_id, reverse=(readingDirection == 'right-to-left')) - file_id = input_file.ID.replace(self.input_file_grp, self.output_file_grp) - if file_id == input_file.ID: - file_id = concat_padded(self.output_file_grp, n) + file_id = make_file_id(input_file, self.output_file_grp) self.workspace.add_file( ID=file_id, file_grp=self.output_file_grp,