Add per label remark, post correction
This commit is contained in:
1 parent
3abd7873e6
commit
8918d64452
13 files changed
+343
-23
No files matched your search
@@ -6,6 +6,7 @@ from pathlib import Path
|
||||
from copienator import atomic_write_json, configuration, read_json
|
||||
from copienator.annotation_documents import copy_documents
|
||||
from copienator.return_answers import load_return_answer_options
|
||||
from copienator.custom_remarks import load_remarks, copy_key
|
||||
|
||||
STATE_FILE = ".annotation-read-state.json"
|
||||
DOCUMENT_INPUTS = ("bnote.json", "checkboxes.json", "Reference.jpg", "Concat_annotated.pdf")
|
||||
@@ -36,7 +37,9 @@ class AnnotationReadCache:
|
||||
shared.extend(directory / name for name in DOCUMENT_INPUTS)
|
||||
common = (_files_digest(shared), load_return_answer_options(root),
|
||||
configuration.RETURN_ANSWERS_ENABLED,
|
||||
configuration.RETURN_JPEG_ENABLED, configuration.RETURN_PDF_ENABLED,
|
||||
configuration.LATEX_ANOT_BEFORE, configuration.LATEX_ANOT_AFTER)
|
||||
remarks = load_remarks(root)
|
||||
for copy_id, labels in data.items():
|
||||
directory = root / mode / f"Copie{copy_id}"
|
||||
paths = [directory / "score.json", directory / "bnote.json"]
|
||||
@@ -45,7 +48,7 @@ class AnnotationReadCache:
|
||||
for content in labels.values():
|
||||
pdf = Path(content["pdf_path"])
|
||||
paths.extend((pdf, pdf.with_suffix(".layout.json")))
|
||||
payload = json.dumps((1, common, labels, _files_digest(paths)),
|
||||
payload = json.dumps((2, common, labels, remarks.get(copy_key(copy_id), {}), _files_digest(paths)),
|
||||
sort_keys=True, default=str).encode()
|
||||
self.signatures[copy_id] = sha256(payload).hexdigest()
|
||||
|
||||
@@ -71,6 +74,9 @@ class AnnotationReadCache:
|
||||
outputs.extend(directory.glob("annotation_baseline.json"))
|
||||
for destination in self.workspace.return_dir.glob(f"* ({copy_id})"):
|
||||
outputs.extend((destination / "answers").glob("*.jpg"))
|
||||
stem = destination.name.rsplit(" (", 1)[0]
|
||||
outputs.extend(path for suffix in (".jpg", ".pdf")
|
||||
if (path := destination / (stem + suffix)).is_file())
|
||||
atomic_write_json(directory / STATE_FILE, {
|
||||
"signature": self.signatures[copy_id],
|
||||
"outputs": [str(path) for path in outputs],
|
||||
|
||||
Reference in new issue
Block a user