step-5: add adaptive chunker

chunker.py splits any revised Markdown (step-4) into RAG-ready chunks.
Supports 4 strategies driven by structure_profile.json: h3_aware,
h2_paragraph_split, paragraph, sliding_window. Respects MIN/MAX_CHARS
and sentence-level overlap. Updates .gitignore and README paths.
This commit is contained in:
2026-04-13 13:36:53 +02:00
parent aa5ae17ca8
commit f80b77ab93
3 changed files with 468 additions and 8 deletions
+8 -8
View File
@@ -370,12 +370,12 @@ git commit -m "step-4: revisione nietzsche completata"
### Step 5 — Chunking adattivo
**Tipo:** automatico
**Input:** `processed/documento/clean.md` + `structure_profile.json`
**Output:** `processed/documento/chunks.json`
**Script:** `scripts/chunker.py`
**Input:** `step-4/<stem>/clean.md` + `step-4/<stem>/structure_profile.json`
**Output:** `step-5/<stem>/chunks.json`
**Script:** `step-5/chunker.py`
```bash
python scripts/chunker.py processed/documento/clean.md --save
python step-5/chunker.py --stem documento
```
Divide il Markdown pulito in chunk. Usa il profilo strutturale
@@ -420,12 +420,12 @@ da solo sarebbe ambiguo.
### Step 6 — Verifica chunk
**Tipo:** automatico
**Input:** `processed/documento/chunks.json`
**Input:** `step-5/<stem>/chunks.json`
**Output:** report problemi + statistiche
**Script:** `scripts/verify_chunks.py`
```bash
python scripts/verify_chunks.py processed/documento/chunks.json
python scripts/verify_chunks.py step-5/documento/chunks.json
```
Analizza ogni chunk e segnala i problemi. Non corregge nulla.
@@ -502,12 +502,12 @@ Ollama è sempre disponibile sul sistema.
### Step 8 — Vettorizzazione
**Tipo:** automatico (lento)
**Input:** `processed/documento/chunks.json`
**Input:** `step-5/<stem>/chunks.json`
**Output:** `chroma_db/` popolato
**Script:** `scripts/ingest.py`
```bash
python scripts/ingest.py processed/documento/chunks.json
python scripts/ingest.py step-5/documento/chunks.json
```
Trasforma ogni chunk in un vettore numerico e lo salva in ChromaDB.