Skip to content

Commit

Permalink
add parameter min_score_style to filter low-confidence font classific…
Browse files Browse the repository at this point in the history
…ation results
  • Loading branch information
kba committed Feb 1, 2024
1 parent 9214280 commit 3eda5f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions ocrd_froc/ocrd-tool.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
"required": false,
"default": true
},
"min_score_style": {
"description": "The minimum score of a font classification to be serialized/used as input for OCR",
"type": "number",
"format": "float",
"required": false,
"default": 0
},
"overwrite_text": {
"description": "Whether to remove any existing TextEquiv before adding text",
"type": "boolean",
Expand Down
6 changes: 5 additions & 1 deletion ocrd_froc/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ def _process_segment(self, segment, image):
continue
fonts_detected.append((typegroup, score))

classification_result = ', '.join([f'{family}:{score}' for family, score in fonts_detected])
classification_result = ', '.join([
f'{family}:{score}' \
for family, score in fonts_detected \
if score > self.parameter['min_score_style']
])

if output_font:
textStyle = segment.get_TextStyle()
Expand Down

0 comments on commit 3eda5f0

Please sign in to comment.