diff --git a/qurator/eynollah/utils/counter.py b/qurator/eynollah/utils/counter.py index 5280c6f..6bd9d7d 100644 --- a/qurator/eynollah/utils/counter.py +++ b/qurator/eynollah/utils/counter.py @@ -20,14 +20,14 @@ class EynollahIdCounter(): self._counter[name] = val def region_id(self, region_idx=None): - if not region_idx: + if region_idx is None: region_idx = self._counter['region'] return REGION_ID_TEMPLATE % region_idx def line_id(self, region_idx=None, line_idx=None): - if not region_idx: + if region_idx is None: region_idx = self._counter['region'] - if not line_idx: + if line_idx is None: line_idx = self._counter['line'] return LINE_ID_TEMPLATE % (region_idx, line_idx) diff --git a/qurator/eynollah/utils/xml.py b/qurator/eynollah/utils/xml.py index b5c5ce3..e972218 100644 --- a/qurator/eynollah/utils/xml.py +++ b/qurator/eynollah/utils/xml.py @@ -41,7 +41,7 @@ def add_textequiv(parent, text=''): unireg = ET.SubElement(textequiv, 'Unicode') unireg.text = text -def xml_reading_order(page, order_of_texts, id_of_texts, id_of_marginalia): +def xml_reading_order(page, order_of_texts, id_of_marginalia): region_order = ET.SubElement(page, 'ReadingOrder') region_order_sub = ET.SubElement(region_order, 'OrderedGroup') region_order_sub.set('id', "ro357564684568544579089") @@ -49,7 +49,7 @@ def xml_reading_order(page, order_of_texts, id_of_texts, id_of_marginalia): for idx_textregion, _ in enumerate(order_of_texts): name = ET.SubElement(region_order_sub, 'RegionRefIndexed') name.set('index', str(region_counter.get('region'))) - name.set('regionRef', region_counter.region_id(order_of_texts[idx_textregion])) + name.set('regionRef', region_counter.region_id(order_of_texts[idx_textregion] + 1)) region_counter.inc('region') for id_marginal in id_of_marginalia: name = ET.SubElement(region_order_sub, 'RegionRefIndexed') diff --git a/qurator/eynollah/writer.py b/qurator/eynollah/writer.py index 3bd68f2..d643941 100644 --- a/qurator/eynollah/writer.py +++ b/qurator/eynollah/writer.py @@ -142,7 +142,7 @@ class EynollahXmlWriter(): id_of_marginalia = [counter_marginals.next_region_id for _ in found_polygons_marginals] if len(found_polygons_text_region) > 0: - xml_reading_order(page, order_of_texts, id_of_texts, id_of_marginalia) + xml_reading_order(page, order_of_texts, id_of_marginalia) for mm in range(len(found_polygons_text_region)): textregion = ET.SubElement(page, 'TextRegion') @@ -188,7 +188,7 @@ class EynollahXmlWriter(): counter_marginals = EynollahIdCounter(region_idx=len(order_of_texts)) id_of_marginalia = [counter_marginals.next_region_id for _ in found_polygons_marginals] - xml_reading_order(page, order_of_texts, id_of_texts, id_of_marginalia) + xml_reading_order(page, order_of_texts, id_of_marginalia) for mm in range(len(found_polygons_text_region)): textregion=ET.SubElement(page, 'TextRegion')