diff --git a/klausur-service/backend/cv_words_first.py b/klausur-service/backend/cv_words_first.py index 307d2ba..e5dd9ed 100644 --- a/klausur-service/backend/cv_words_first.py +++ b/klausur-service/backend/cv_words_first.py @@ -190,10 +190,11 @@ def _build_cells( word_boxes = [] for w in sorted(cell_words, key=lambda ww: (ww['top'], ww['left'])): raw_text = w.get('text', '').strip() - # Split by whitespace AND at "[" boundaries (IPA without space) + # Split by whitespace, at "[" boundaries (IPA), and after leading "!" # e.g. "badge[bxd3]" → ["badge", "[bxd3]"] # e.g. "profit['proft]" → ["profit", "['proft]"] - tokens = re.split(r'\s+|(?=\[)', raw_text) + # e.g. "!Betonung" → ["!", "Betonung"] + tokens = re.split(r'\s+|(?=\[)|(?<=!)(?=[A-Za-z\u00c0-\u024f])', raw_text) tokens = [t for t in tokens if t] # remove empty strings if len(tokens) <= 1: # Single word — keep as-is