Skip to content

Commit 43e4c9c

Browse files
JBBallingbertsky
authored andcommitted
fixed parameter in save_image_file(), updated classes-parameter to type array
1 parent 1d3bb07 commit 43e4c9c

2 files changed

Lines changed: 27 additions & 6 deletions

File tree

ocrd_segment/extract_regions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ def process(self):
6767
assert_file_grp_cardinality(self.input_file_grp, 1)
6868
assert_file_grp_cardinality(self.output_file_grp, 1)
6969
classes = dict(CLASSES)
70+
LOG.info("Extracting %s region classes!" % self.parameter["classes"])
7071
# extract specific classes only
7172
if self.parameter["classes"]:
72-
selected_classes = self.parameter["classes"].split(",")
73+
selected_classes = self.parameter["classes"]
7374
classes = { region: classes[region] for region in selected_classes }
7475
# pylint: disable=attribute-defined-outside-init
7576
for n, input_file in enumerate(self.input_files):
@@ -169,7 +170,7 @@ def process(self):
169170
region_image,
170171
file_id,
171172
self.output_file_grp,
172-
pageId=input_file.pageId,
173+
page_id=input_file.pageId,
173174
mimetype=self.parameter['mimetype'])
174175
self.workspace.add_file(
175176
ID=file_id + '.json',

ocrd_segment/ocrd-tool.json

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,28 @@
292292
"description": "Comma-separated list of forbidden image features (e.g. `binarized,despeckled`)."
293293
},
294294
"classes": {
295-
"type": "string",
296-
"enum": [
295+
"type": "array",
296+
"items": {
297+
"type": "string",
298+
"enum": [
299+
"NoiseRegion",
300+
"LineDrawingRegion",
301+
"AdvertRegion",
302+
"ImageRegion",
303+
"ChartRegion",
304+
"MusicRegion",
305+
"GraphicRegion",
306+
"UnknownRegion",
307+
"CustomRegion",
308+
"SeparatorRegion",
309+
"MathsRegion",
310+
"TextRegion",
311+
"MapRegion",
312+
"ChemRegion",
313+
"TableRegion"
314+
]
315+
},
316+
"default": [
297317
"NoiseRegion",
298318
"LineDrawingRegion",
299319
"AdvertRegion",
@@ -309,8 +329,8 @@
309329
"MapRegion",
310330
"ChemRegion",
311331
"TableRegion"
312-
],
313-
"description": "Comma-separated string of region types to extract e.g. 'TextRegion,TableRegion,ImageRegion'. If empty, all regions are allowed."
332+
],
333+
"description": "Array of region types to extract e.g. -P classes '[\"TextRegion\", \"TableRegion\", \"ImageRegion\"]' . If empty, all regions are allowed."
314334
},
315335
"mimetype": {
316336
"type": "string",

0 commit comments

Comments
 (0)