This commit is contained in:
team3
2026-06-29 00:09:24 +02:00
parent 07b6736ced
commit bf7ebe045b
8 changed files with 483 additions and 40 deletions

View File

@@ -55,6 +55,14 @@ def _titel_aufloesen(idx: dict[str, int], t: str) -> int | None:
return idx.get(_norm_titel(t)) or idx.get(_norm_titel(_titel(t)))
def _norm_dash(s: str) -> str:
"""Space-umgebene Dash-Varianten (en/em/figure/bar/hyphen) → einheitlicher Trenner ''.
Manche Modelle (v.a. nicht-westliche) setzen statt des Em-Dashs einen En-Dash „–"; ohne
Normalisierung scheitert der ` — `-Split komplett und der ganze Eintrag wird zum Titel.
ASCII-Bindestrich „-" bleibt unangetastet (sonst zerlegt es Formeln wie „n - 1")."""
return re.sub(r"\s+[‒–—―‐]\s+", "", s)
def _parse_auswahl(text: str) -> dict[int, str]:
"""Parst eine Baustein-Liste: `N. Titel — Kurzbeschreibung` pro Zeile."""
entries: dict[int, str] = {}
@@ -63,9 +71,9 @@ def _parse_auswahl(text: str) -> dict[int, str]:
m = re.match(r"\s*(\d+)[.)]\s+(.*\S)", line)
if m:
last = int(m.group(1))
entries[last] = m.group(2)
entries[last] = _norm_dash(m.group(2))
elif last is not None and line.strip():
entries[last] += " " + line.strip()
entries[last] += " " + _norm_dash(line.strip())
return entries