From 95c5ab93026f9ba810cdbeb926ef92422a3a0e69 Mon Sep 17 00:00:00 2001 From: Sven Geboers Date: Sun, 29 Mar 2026 19:26:43 +0200 Subject: [PATCH] fix: generate interpretation string when motion path wins without ideology --- analysis/axis_classifier.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/analysis/axis_classifier.py b/analysis/axis_classifier.py index f633ce9..f0fe24e 100644 --- a/analysis/axis_classifier.py +++ b/analysis/axis_classifier.py @@ -43,6 +43,13 @@ _INTERPRETATION_TEMPLATES = { ), } +# Maps motion-path keyword labels to _INTERPRETATION_TEMPLATES keys. +# Labels not present here fall back to "fallback". +_MOTION_LABEL_TEMPLATE_KEY: Dict[str, str] = { + "Links\u2013Rechts": "lr", + "Progressief\u2013Conservatief": "pc", +} + # Simple keyword-based classifier for motion titles (fallback signal) _KEYWORD_THRESHOLD = 0.4 @@ -512,8 +519,18 @@ def classify_axes( if x_kw_lbl is not None: x_lbl = x_kw_lbl + if not x_int: + tkey = _MOTION_LABEL_TEMPLATE_KEY.get(x_kw_lbl, "fallback") + x_int = _INTERPRETATION_TEMPLATES[tkey].format( + orientation="horizontale" + ) if y_kw_lbl is not None: y_lbl = y_kw_lbl + if not y_int: + tkey = _MOTION_LABEL_TEMPLATE_KEY.get(y_kw_lbl, "fallback") + y_int = _INTERPRETATION_TEMPLATES[tkey].format( + orientation="verticale" + ) # Build display lists: [(title, date), ...] for pole, ids in x_ids.items():