Keep empty answers in the final individual outputs.
This commit is contained in:
1 parent
b1f1e0bc86
commit
e7094d850e
8 files changed
+164
-37
No files matched your search
@@ -155,7 +155,7 @@ def output_removals(directory: Path) -> tuple[str, ...]:
|
||||
info = read_json(directory / "info.json") if (directory / "info.json").exists() else {}
|
||||
return ("Concat.jpg", "Concat_F.jpg", "Concat_F.pdf", "touched.json", "answer_labels.json",
|
||||
*(f"{label}.jpg" for label, entry in info.items()
|
||||
if entry.get("not_empty") and Path(label).name == label))
|
||||
if Path(label).name == label))
|
||||
|
||||
|
||||
def rebuild(root: Path, mode: str, directory: Path, staging: Path, meta: dict,
|
||||
@@ -169,7 +169,15 @@ def rebuild(root: Path, mode: str, directory: Path, staging: Path, meta: dict,
|
||||
|
||||
headers, bodies, changed = edited_bodies(directory, meta, instructions)
|
||||
info = deepcopy(meta["info"])
|
||||
filtered = set(meta["filtered"]) | changed
|
||||
for label, entry in info.items():
|
||||
# Retained empty scans are images, not evidence of a non-empty answer.
|
||||
entry["not_empty"] = label in bodies and (entry["not_empty"] or label in changed)
|
||||
if label in changed:
|
||||
entry["present"] = label in bodies
|
||||
entry["score"] = scores.get(label, entry["score"])
|
||||
filtered = (set(meta["filtered"]) | changed) & {
|
||||
label for label, entry in info.items() if entry["not_empty"]
|
||||
}
|
||||
all_labels = utils.read_all_labels(root)
|
||||
images, groups = [], []
|
||||
seen_contexts = set()
|
||||
@@ -187,15 +195,13 @@ def rebuild(root: Path, mode: str, directory: Path, staging: Path, meta: dict,
|
||||
fill="black", font_size=30)
|
||||
image = stack([header, body])
|
||||
image.save(staging / f"{label}.jpg")
|
||||
images.append(image)
|
||||
if info[label]["not_empty"]:
|
||||
images.append(image)
|
||||
if label in filtered:
|
||||
extras = get_extra_pdfs_as_images(root, label, annotating, all_labels,
|
||||
seen_contexts=seen_contexts) if mode == "BGnot" else []
|
||||
groups.append([*extras, image])
|
||||
for label, entry in info.items():
|
||||
entry["not_empty"] = label in bodies
|
||||
if label in changed and label in bodies:
|
||||
entry["present"] = True
|
||||
entry["touched"] = mode == "BGnot" and label in bodies and label in filtered
|
||||
entry["score"] = scores.get(label, entry["score"])
|
||||
atomic_write_json(staging / "info.json", info)
|
||||
|
||||
Reference in new issue
Block a user