mirror of
https://github.com/qurator-spk/eynollah.git
synced 2025-06-08 19:59:56 +02:00
eliminate id_of_texts from xml_reading_order, fix plus one error
This commit is contained in:
parent
6c60d9e90a
commit
a3465ca1a0
3 changed files with 7 additions and 7 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue