From 87e7ba67eca9a44b24919bc2a3d72fc63e62afd9 Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Wed, 15 Apr 2026 13:33:39 +0200 Subject: [PATCH] fix(step-6): riconosci _word._ come terminatore valido in verify_chunks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rimuove falsi positivi per chunk che terminano con marcatori markdown di enfasi (_) dopo punteggiatura di fine frase (es. _parola._). Aggiunge U+2026 (…) alla lista di terminatori accettati. --- step-6/verify_chunks.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/step-6/verify_chunks.py b/step-6/verify_chunks.py index 53f676f..d8eb125 100644 --- a/step-6/verify_chunks.py +++ b/step-6/verify_chunks.py @@ -26,7 +26,7 @@ from pathlib import Path MIN_CHARS = 200 MAX_CHARS = 800 -PUNCT_END = re.compile("[.!?»)\\]'\u2019\"\u201c\u201d\u2018\u2014\u2013-]$") +PUNCT_END = re.compile("[.!?»)\\]'\u2019\"\u201c\u201d\u2018\u2014\u2013\u2026-]$") # ─── Checks ─────────────────────────────────────────────────────────────────── @@ -53,8 +53,12 @@ def ends_incomplete(chunk: dict) -> bool: text = chunk.get("text", "").rstrip() if not text: return False - # Controlla l'ultimo carattere non-whitespace - return not PUNCT_END.search(text) + # Rimuovi marcatori markdown finali (_ e *) prima di controllare: + # pattern come _parola._ o _parola!_ sono frasi complete. + text_check = re.sub(r"[_*]+$", "", text).rstrip() + if not text_check: + return False + return not PUNCT_END.search(text_check) # ─── Report ───────────────────────────────────────────────────────────────────