Skip to content

Commit

Permalink
add warning for missing baseline points
Browse files Browse the repository at this point in the history
  • Loading branch information
shigapov committed Sep 13, 2022
1 parent 9df32bd commit 0060c9c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion blatt/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ def _parse_page_xml(self):
for text_region_id, text_region in enumerate(self.root.iter('{%s}TextRegion' % self.namespace)):
for text_line in text_region.findall('{%s}TextLine' % self.namespace):
text_line_id = text_line.attrib['id']
text_line_bs = text_line.find('{%s}Baseline' % self.namespace).attrib['points']
try:
text_line_bs = text_line.find('{%s}Baseline' % self.namespace).attrib['points']
except (Exception,):
print('Warning! No "Baseline points" for "TextLine id"=' +
text_line_id + ' in "file"=' + Path(self.filename).name)
coordinates = [c.split(',') for c in text_line_bs.split(' ')]
coordinates = [[int(c[0]), int(c[1])] for c in coordinates]
self.baselines.extend(coordinates)
Expand Down

0 comments on commit 0060c9c

Please sign in to comment.