- Aggiunge 10 pagine concetto, 5 composti e 6 tecniche, riorganizzate per argomento con tesi_loc e righe di raw/tesi.md - Incorpora le figure (embed e link alle note) nelle pagine pertinenti - Aggiunge overview, mappa wiki/tesi.md, difetti-noti (incoerenze rilevate) e bibliografia generata (scripts/gen_bibliografia.py) - Rigenera le note figura con avviso per caption_mismatch; aggiorna CLAUDE.md, index.md e log.md Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
72 lines
3.2 KiB
Python
72 lines
3.2 KiB
Python
"""Genera wiki/figures/<id>.md da raw/immagini.json. Nessun riassunto: ogni campo del catalogo viene riportato.
|
||
Uso: python scripts/gen_figures.py (rigenera tutto; le note sono derivate, non si modificano a mano)."""
|
||
import json
|
||
from pathlib import Path
|
||
|
||
root = Path(__file__).resolve().parent.parent
|
||
cat = json.loads((root / "raw/immagini.json").read_text(encoding="utf8"))
|
||
out = root / "wiki/figures"
|
||
out.mkdir(parents=True, exist_ok=True)
|
||
|
||
|
||
def q(s):
|
||
return json.dumps(str(s), ensure_ascii=False)
|
||
|
||
|
||
def lst(xs):
|
||
return "[" + ", ".join(q(x) for x in xs) + "]"
|
||
|
||
|
||
for f in cat["figures"]:
|
||
loc, qual = f["location"], f["quality"]
|
||
f["label"] = f.get("label") or f["id"] # figure senza numero stampato
|
||
v = qual.get("verification") or {}
|
||
tesi_loc = f"§{loc['section']} r.{loc['md_line']}"
|
||
fm = [
|
||
"---",
|
||
f"title: {q(' - '.join(x for x in (f['label'], f.get('title') or f.get('caption_printed')) if x))}",
|
||
"type: figure",
|
||
f"id: {f['id']}",
|
||
f"tipo: {f['type']}",
|
||
f"capitolo: {q(loc['chapter'])}",
|
||
f"sezione: {q(loc['section'])}",
|
||
f"tesi_loc: {q(tesi_loc)}",
|
||
f"composti: {lst(f.get('compounds', []))}",
|
||
f"concetti: {lst(f.get('concepts', []))}",
|
||
f"keywords: {lst(f.get('keywords', []))}",
|
||
f"confidence: {qual['confidence']}",
|
||
f"flags: {lst(qual.get('flags', []))}",
|
||
f"verifica: {v.get('verdict', 'n/d')}",
|
||
"derivata: true",
|
||
"---",
|
||
"",
|
||
]
|
||
body = [f"# {f['label']}", ""]
|
||
body += [f"**Didascalia stampata (testo della tesi):** {f.get('caption_printed') or 'n/d'}", ""]
|
||
cap = f", didascalia r.{loc['caption_md_line']}" if loc.get("caption_md_line") else ""
|
||
body += [f"_Posizione: tesi.md {tesi_loc} (sezione {loc['section']} {loc['section_title']}){cap}_", ""]
|
||
if "caption_mismatch" in qual.get("flags", []):
|
||
body += ["> ⚠ Flag `caption_mismatch`: la didascalia stampata qui sopra è quella attribuita dal catalogo e potrebbe non descrivere l'immagine (vedi «Didascalia generata» e «Da verificare»).", ""]
|
||
body += ["> Sotto: contenuto generato guardando l'immagine, non verificato una per una.", ""]
|
||
body += [f"**Didascalia generata:** {f['caption']}", ""]
|
||
for p in f["panels"]:
|
||
body += [p["embed"], ""]
|
||
body += [f"- Pannello: {p['panel'] or 'unico'} · file `{p['file']}` · {p['width']}×{p['height']} · confidence {p['confidence']}"]
|
||
body += [f"- Descrizione: {p['description']}"]
|
||
body += ["- Testo visibile: " + (" · ".join(p["visible_text"]) or "n/d")]
|
||
if p.get("quality_flags"):
|
||
body += ["- Flag: " + ", ".join(p["quality_flags"])]
|
||
body += [""]
|
||
if f.get("text_context"):
|
||
body += ["## Contesto nel testo", f["text_context"], ""]
|
||
if f.get("cited_in_md_lines"):
|
||
body += ["Citata in tesi.md alle righe: " + ", ".join(map(str, f["cited_in_md_lines"])), ""]
|
||
if qual.get("review_notes"):
|
||
body += ["## Da verificare", qual["review_notes"], ""]
|
||
if v.get("issues"):
|
||
body += ["Esito revisione indipendente: " + "; ".join(v["issues"]), ""]
|
||
body += ["## Collegamenti", "- [[tesi]]", ""]
|
||
(out / f"{f['id']}.md").write_text("\n".join(fm + body), encoding="utf8")
|
||
|
||
print(f"{len(cat['figures'])} note in {out}")
|