Skip to content

Commit

Permalink
new processor replace-text
Browse files Browse the repository at this point in the history
  • Loading branch information
bertsky committed May 29, 2022
1 parent eafa503 commit c0a0b47
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Versioned according to [Semantic Versioning](http://semver.org/).

## Unreleased

Added:

* replace-text: new processor (inverse of extract-* for text)

Fixed:

* repair/project: use minimum spanning tree when joining polygons
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Contains processors for various tasks:
- [ocrd-segment-project](ocrd_segment/project.py) (remake segment coordinates into the concave hull / alpha shape of their constituents)
- [ocrd-segment-replace-original](ocrd_segment/replace_original.py) (rebase all segments on cropped+deskewed border frame as new full page)
- [ocrd-segment-replace-page](ocrd_segment/replace_page.py) (2 input fileGrps; overwrite segmentation below page of first fileGrp by all segments of second fileGrp, rebasing all coordinates; "inverse" of `replace-original`)
- [ocrd-segment-replace-text](ocrd_segment/replace_text.py) (insert text below page from single-segment text files; "inverse" of `extract-*`)
- comparing different layout segmentations:
- [ocrd-segment-evaluate](ocrd_segment/evaluate.py) :construction: (2 input fileGrps; align, compare and evaluate page segmentations; early stage)
- [page-segment-evaluate](ocrd_segment/evaluate.py) (same with standalone CLI)
Expand Down
6 changes: 6 additions & 0 deletions ocrd_segment/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .evaluate import EvaluateSegmentation
from .replace_original import ReplaceOriginal
from .replace_page import ReplacePage
from .replace_text import ReplaceText
from .extract_pages import ExtractPages
from .extract_regions import ExtractRegions
from .extract_lines import ExtractLines
Expand Down Expand Up @@ -49,6 +50,11 @@ def ocrd_segment_replace_original(*args, **kwargs):
def ocrd_segment_replace_page(*args, **kwargs):
return ocrd_cli_wrap_processor(ReplacePage, *args, **kwargs)

@click.command()
@ocrd_cli_options
def ocrd_segment_replace_text(*args, **kwargs):
return ocrd_cli_wrap_processor(ReplaceText, *args, **kwargs)

@click.command()
@ocrd_cli_options
def ocrd_segment_extract_pages(*args, **kwargs):
Expand Down
13 changes: 13 additions & 0 deletions ocrd_segment/ocrd-tool.json
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,19 @@
}
}
},
"ocrd-segment-replace-text": {
"executable": "ocrd-segment-replace-text",
"categories": ["Text recognition and optimization"],
"description": "Insert text from annotations in single-segment text files",
"steps": ["recognition/post-correction"],
"parameters": {
"file_glob": {
"type": "string",
"default": "*.gt.txt",
"description": "glob expression which expands to file names to match against page IDs and segment IDs in order to be ingested"
}
}
},
"ocrd-segment-evaluate": {
"executable": "ocrd-segment-evaluate",
"categories": ["Layout analysis"],
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- ocrd-segment-extract-glyphs
- ocrd-segment-replace-original
- ocrd-segment-replace-page
- ocrd-segment-replace-text
- ocrd-segment-evaluate
- page-segment-evaluate
"""
Expand Down Expand Up @@ -52,6 +53,7 @@
'ocrd-segment-extract-glyphs=ocrd_segment.cli:ocrd_segment_extract_glyphs',
'ocrd-segment-replace-original=ocrd_segment.cli:ocrd_segment_replace_original',
'ocrd-segment-replace-page=ocrd_segment.cli:ocrd_segment_replace_page',
'ocrd-segment-replace-text=ocrd_segment.cli:ocrd_segment_replace_text',
'ocrd-segment-evaluate=ocrd_segment.cli:ocrd_segment_evaluate',
'page-segment-evaluate=ocrd_segment.evaluate:standalone_cli',
]
Expand Down

0 comments on commit c0a0b47

Please sign in to comment.