From 9723dfeb73d416424ca432fbc0ce683eef7bcbad Mon Sep 17 00:00:00 2001 From: Robert Sachunsky Date: Thu, 23 Apr 2026 23:46:23 +0200 Subject: [PATCH] =?UTF-8?q?writer:=20also=20annotate=20col-classifier=20re?= =?UTF-8?q?sult=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit both notations: - in `/PcGts/Page/@custom` (CSS-style) - in `/PcGts/Metadata/Comment` (qurator-style) --- src/eynollah/eynollah.py | 4 ++++ src/eynollah/writer.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/eynollah/eynollah.py b/src/eynollah/eynollah.py index dad2d53..90d59fd 100644 --- a/src/eynollah/eynollah.py +++ b/src/eynollah/eynollah.py @@ -2253,6 +2253,7 @@ class Eynollah: conf_contours_textregions =[0] pcgts = writer.build_pagexml_no_full_layout( + num_col=num_col_classifier, found_polygons_text_region=cont_page, page_coord=page_coord, order_of_texts=order_text_new, @@ -2323,6 +2324,7 @@ class Eynollah: self.logger.info("No columns detected - generating empty PAGE-XML") pcgts = writer.build_pagexml_no_full_layout( + num_col=0, found_polygons_text_region=[], page_coord=page_coord, page_slope=slope_deskew, @@ -2612,6 +2614,7 @@ class Eynollah: if self.full_layout: pcgts = writer.build_pagexml_full_layout( + num_col=num_col_classifier, found_polygons_text_region=polygons_of_textregions, found_polygons_text_region_h=polygons_of_textregions_h, page_coord=page_coord, @@ -2642,6 +2645,7 @@ class Eynollah: ) else: pcgts = writer.build_pagexml_no_full_layout( + num_col=num_col_classifier, found_polygons_text_region=polygons_of_textregions, page_coord=page_coord, page_slope=slope_deskew, diff --git a/src/eynollah/writer.py b/src/eynollah/writer.py index b867d9e..a705a16 100644 --- a/src/eynollah/writer.py +++ b/src/eynollah/writer.py @@ -71,6 +71,7 @@ class EynollahXmlWriter: def build_pagexml_no_full_layout( self, *, + num_col, found_polygons_text_region, page_coord, page_slope, @@ -98,6 +99,7 @@ class EynollahXmlWriter: conf_tables=None, ): return self.build_pagexml_full_layout( + num_col=num_col, found_polygons_text_region=found_polygons_text_region, found_polygons_text_region_h=[], page_coord=page_coord, @@ -131,6 +133,7 @@ class EynollahXmlWriter: def build_pagexml_full_layout( self, *, + num_col, found_polygons_text_region, found_polygons_text_region_h, page_coord, @@ -171,6 +174,8 @@ class EynollahXmlWriter: pcgts = self.pcgts if self.pcgts else create_page_xml( self.image_filename, self.image_height, self.image_width) page = pcgts.get_Page() + pcgts.Metadata.Comments = "num_col %d" % num_col + page.set_custom('layout {num_col:%d;} ' % num_col) page.set_orientation(-page_slope) if len(cont_page): page.set_Border(BorderType(Coords=CoordsType(points=self.calculate_points(cont_page[0]))))