add MetadataItem about processor

pull/6/head
Robert Sachunsky 5 years ago
parent ad8f25666b
commit e16438a377

@ -7,6 +7,7 @@ from ocrd import Processor
from ocrd_modelfactory import page_from_file from ocrd_modelfactory import page_from_file
from ocrd_models.ocrd_page import ( from ocrd_models.ocrd_page import (
TextRegionType, TextLineType, WordType, TextRegionType, TextLineType, WordType,
MetadataItemType, LabelsType, LabelType,
to_xml to_xml
) )
from ocrd_utils import ( from ocrd_utils import (
@ -35,6 +36,19 @@ class RepairInconsistencies(Processor):
pcgts = page_from_file(self.workspace.download_file(input_file)) pcgts = page_from_file(self.workspace.download_file(input_file))
page = pcgts.get_Page() page = pcgts.get_Page()
# add metadata about this operation and its runtime parameters:
metadata = pcgts.get_Metadata() # ensured by from_file()
metadata.add_MetadataItem(
MetadataItemType(type_="processingStep",
name=self.ocrd_tool['steps'][0],
value=TOOL,
Labels=[LabelsType(
externalModel="ocrd-tool",
externalId="parameters",
Label=[LabelType(type_=name,
value=self.parameter[name])
for name in self.parameter.keys()])]))
regions = page.get_TextRegion() regions = page.get_TextRegion()
for region in regions: for region in regions:

Loading…
Cancel
Save