Sven Geboers
a3154f72df
refactor: extract shared helpers to common.py, fix bugs, add TDD tests
...
- Created analysis/right_wing/common.py with all shared helpers:
Constants: CANONICAL_CENTRIST, COALITION, BREAK_YEAR, etc.
Functions: _conn, cohens_d, build_party_name_map, parse_lead_submitter,
motion_passed, quarter_sort_key, find_inflection_point
- Fixed bugs:
1. ai_provider.py: requests.Timeout now caught alongside ConnectionError
2. voting_margin.py: Removed walrus operator misuse, fixed Mann-Whitney test
- Updated 13 consuming files to import from common.py
- Added 35 TDD tests in tests/right_wing/test_common.py
- 282 tests pass (was 247)
3 weeks ago
Sven Geboers
364c312076
fix(right-wing): update DB with latest motions, fix DROP TABLE bug, score all missing 2D
...
- Fetched 276 new motions from Tweede Kamer API (2026-04-23 to 2026-05-31)
- Fixed classify_motions.py: DROP TABLE → CREATE TABLE IF NOT EXISTS
- Restored derived columns (centrist_support_strict, category, etc.) via migration
- Scored 180 missing motions in extremity_scores_2d (now 3,049 total, 0 missing)
- Re-ran temporal trajectory with updated data (inflection: 2024-Q2)
3 weeks ago
Sven Geboers
d3dfb0ce2f
feat(right-wing): hybrid motion classifier using keywords + votes
...
Implements U2: classify_motions.py loads keywords from U1 and classifies
motions as right-wing when:
- right_support >= 60% (CANONICAL_RIGHT parties voting 'voor')
- left_opposition >= 40% (CANONICAL_LEFT parties voting 'tegen')
- AND at least 1 right-wing keyword match in title/body_text
Outputs DuckDB table with:
- motion_id, year, title, right_support, left_opposition, centrist_support
- right_keyword_matches, left_keyword_matches, classified flag
Classified 2986 of 28331 motions (10.5%) as right-wing.
1 month ago