From 7773c513046b598685fabf23965a422e69026569 Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Wed, 25 Mar 2026 08:37:15 +0100 Subject: [PATCH] Fix en/de mode edge case on docs without detected English column When no IPA signals exist (e.g. German-only dicts), the fallback that guesses en_col_type was incorrectly triggered for en/de modes, causing false IPA and syllable insertions. Now only fires for 'all' mode. Syllable en mode also returns empty set when no EN column found. Co-Authored-By: Claude Opus 4.6 --- klausur-service/backend/grid_editor_api.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/klausur-service/backend/grid_editor_api.py b/klausur-service/backend/grid_editor_api.py index 82c04ad..0ba002f 100644 --- a/klausur-service/backend/grid_editor_api.py +++ b/klausur-service/backend/grid_editor_api.py @@ -889,8 +889,8 @@ async def _build_grid_core( col_ipa_count[ct] = col_ipa_count.get(ct, 0) + 1 if col_ipa_count: en_col_type = max(col_ipa_count, key=col_ipa_count.get) - elif ipa_mode in ("all", "de", "en"): - # Force mode without auto-detection: pick column with most cells + elif ipa_mode == "all": + # Force-all mode without auto-detection: pick column with most cells col_cell_count: Dict[str, int] = {} for cell in all_cells: ct = cell.get("col_type", "") @@ -1510,10 +1510,12 @@ async def _build_grid_core( _syllable_eligible = True # For language-specific modes, determine allowed columns _syllable_col_filter: Optional[set] = None # None = all columns - if syllable_mode == "en" and en_col_type: - _syllable_col_filter = {en_col_type} - elif syllable_mode == "de" and en_col_type: - _syllable_col_filter = all_content_cols - {en_col_type} if total_cols >= 3 else None + if syllable_mode == "en": + _syllable_col_filter = {en_col_type} if en_col_type else set() + elif syllable_mode == "de": + if en_col_type and total_cols >= 3: + _syllable_col_filter = all_content_cols - {en_col_type} + # else None → all columns (correct for German-only dicts) if _syllable_eligible: try: from cv_syllable_detect import insert_syllable_dividers