fix: aggiorna path step-4/ → conversione/ e riferimenti step-X

- chunker.py: input da conversione/<stem>/ (era step-4/, non esistente)
- verify_chunks.py: messaggi errore aggiornati a conversione/
- config.py: commenti step-8 → ingest.py
This commit is contained in:
2026-04-19 00:03:43 +02:00
parent 719559354a
commit fa15e06e35
3 changed files with 22 additions and 22 deletions
+16 -16
View File
@@ -1,15 +1,15 @@
#!/usr/bin/env python3
"""
Step 5 — Chunking adattivo
Chunking adattivo
Divide il Markdown revisionato (step 4) in chunk semantici pronti per la
Divide il Markdown revisionato in chunk semantici pronti per la
vettorizzazione. La strategia dipende dal profilo strutturale del documento.
Input: step-4/<stem>/clean.md + step-4/<stem>/structure_profile.json
Input: conversione/<stem>/clean.md + conversione/<stem>/structure_profile.json
Output: step-5/<stem>/chunks.json
Uso:
python step-5/chunker.py # tutti i documenti in step-4/
python step-5/chunker.py # tutti i documenti in conversione/
python step-5/chunker.py --stem documento # un solo documento
python step-5/chunker.py --stem documento --force
"""
@@ -375,19 +375,19 @@ def chunk_document(clean_md: Path, profile: dict, stem: str) -> list[dict]:
# ─── Per-document processing ──────────────────────────────────────────────────
def process_stem(stem: str, project_root: Path, force: bool) -> bool:
step4_dir = project_root / "step-4" / stem
conv_dir = project_root / "conversione" / stem
out_dir = project_root / "step-5" / stem
clean_md = step4_dir / "clean.md"
profile_path = step4_dir / "structure_profile.json"
clean_md = conv_dir / "clean.md"
profile_path = conv_dir / "structure_profile.json"
out_file = out_dir / "chunks.json"
print(f"\nDocumento: {stem}")
if not clean_md.exists():
print(f" ✗ clean.md non trovato in step-4/{stem}/ — skip")
print(f" ✗ clean.md non trovato in conversione/{stem}/ — skip")
return False
if not profile_path.exists():
print(f" ✗ structure_profile.json non trovato in step-4/{stem}/ — skip")
print(f" ✗ structure_profile.json non trovato in conversione/{stem}/ — skip")
return False
if out_file.exists() and not force:
@@ -432,21 +432,21 @@ def process_stem(stem: str, project_root: Path, force: bool) -> bool:
if __name__ == "__main__":
project_root = Path(__file__).parent.parent
parser = argparse.ArgumentParser(description="Step 5 — Chunking adattivo")
parser.add_argument("--stem", help="Nome del documento (sottocartella di step-4/)")
parser = argparse.ArgumentParser(description="Chunking adattivo")
parser.add_argument("--stem", help="Nome del documento (sottocartella di conversione/)")
parser.add_argument("--force", action="store_true", help="Riesegui anche se già presente")
args = parser.parse_args()
if args.stem:
stems = [args.stem]
else:
step4_dir = project_root / "step-4"
if not step4_dir.exists():
print(f"Errore: cartella step-4/ non trovata in {project_root}")
conv_dir = project_root / "conversione"
if not conv_dir.exists():
print(f"Errore: cartella conversione/ non trovata in {project_root}")
sys.exit(1)
stems = sorted(p.name for p in step4_dir.iterdir() if p.is_dir())
stems = sorted(p.name for p in conv_dir.iterdir() if p.is_dir() and (p / "clean.md").exists())
if not stems:
print(f"Errore: nessun documento trovato in step-4/")
print(f"Errore: nessun documento trovato in conversione/")
sys.exit(1)
results = [process_stem(s, project_root, args.force) for s in stems]