This commit is contained in:
root
2026-07-01 20:00:57 +00:00
parent a2a5da25df
commit afa8b36105
10 changed files with 945 additions and 62 deletions

View File

@@ -56,11 +56,14 @@ def _resolve_title(idx: dict[str, int], t: str) -> int | None:
def _norm_dash(s: str) -> str:
"""Space-surrounded dash variants (en/em/figure/bar/hyphen) → uniform separator ''.
"""Dash variants (en/em/figure/bar) with whitespace on AT LEAST ONE side → uniform separator ''.
Some models (especially non-western ones) use an en-dash "" instead of the em-dash; without
normalization the ` — ` split fails entirely and the whole entry becomes the title.
The ASCII hyphen "-" is left untouched (otherwise it would split formulas like "n - 1")."""
return re.sub(r"\s+[‒–—―‐]\s+", "", s)
normalization the ` — ` split fails entirely and the whole entry becomes the title. A one-sided
space ("Titel —Beschreibung" / "Titel— Beschreibung") also breaks the split and leaks the source
filename into the description — so a dash with a space on either side is repaired too. The ASCII
hyphen "-" is deliberately NOT in the class (would split "n - 1"/"3-SAT"); requiring ≥1 surrounding
space keeps glued compounds like "Backtracking—Verfahren" and number ranges like "1215" untouched."""
return re.sub(r"\s*[‒–—―]\s+|\s+[‒–—―]\s*", "", s)
def _parse_selection(text: str) -> dict[int, str]: