Initial commit for finalisation web interface
This commit is contained in:
1 parent
b295f871a7
commit
c36642e8de
33 files changed
+2745
-138
No files matched your search
@@ -0,0 +1,38 @@
|
||||
"""Re-render saved handwriting interpretation with current scores and remarks."""
|
||||
from copienator import EvaluationWorkspace, ExitCode, evaluation_parser, execute, workspace_from_args, utils
|
||||
from copienator.review_snapshot import load, FILENAME
|
||||
from copienator.commands.reading_annotations import apply_actions_and_regenerate
|
||||
from copienator.commands.reading_grouped_annotations import apply_actions_and_regenerate_grouped
|
||||
|
||||
|
||||
def run(workspace: EvaluationWorkspace, mode: str):
|
||||
directories = sorted((p for p in (workspace.root / mode).glob('Copie*')
|
||||
if p.is_dir() and p.name[5:].isdigit() and (p / 'score.json').is_file()))
|
||||
# Validate every snapshot before starting to publish any copy.
|
||||
for directory in directories:
|
||||
if not (directory / FILENAME).is_file():
|
||||
raise ValueError(f'{directory.name} : résultat de lecture sauvegardé absent ; relisez les annotations manuscrites.')
|
||||
load(workspace.root, directory)
|
||||
status = ExitCode.SUCCESS
|
||||
for directory in directories:
|
||||
cid = directory.name[5:]
|
||||
saved, data, notes = load(workspace.root, directory)
|
||||
if saved['engine'] == 'standard':
|
||||
result = apply_actions_and_regenerate(workspace, {cid: data}, cid, [], None,
|
||||
utils.read_all_labels(workspace.root), update_score=True,
|
||||
label_notes={label: note['img'] for label, note in notes.items()},
|
||||
review_metadata=saved['bnote'])
|
||||
else:
|
||||
result, log = apply_actions_and_regenerate_grouped(workspace, {cid: data}, cid, [], notes,
|
||||
utils.read_all_labels(workspace.root), update_score=True, annotation_dir=mode,
|
||||
force_filtered=set(saved.get('force_filtered', [])))
|
||||
print(log, flush=True)
|
||||
if result != ExitCode.SUCCESS:
|
||||
status = ExitCode.PARTIAL
|
||||
return status
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
parser = evaluation_parser('Regenerate from saved reviewed inputs without rescanning handwriting')
|
||||
parser.add_argument('--annotation-dir', choices=('Bnot', 'BGnot'), required=True)
|
||||
return execute(parser, argv, lambda args: run(workspace_from_args(args), args.annotation_dir))
|
||||
Reference in new issue
Block a user