|
|
|
|
@ -179,6 +179,35 @@ def load_party_map(db_path: str) -> Dict[str, str]: |
|
|
|
|
return {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@st.cache_data(show_spinner="Partijposities op SVD-assen laden…") |
|
|
|
|
def load_party_axis_scores(db_path: str) -> Dict[str, List[float]]: |
|
|
|
|
"""Return per-party SVD vectors for window='2025'. |
|
|
|
|
|
|
|
|
|
Queries svd_vectors WHERE entity_type='mp' AND window_id='2025' |
|
|
|
|
AND entity_id is a known current-parliament party. |
|
|
|
|
|
|
|
|
|
Returns: |
|
|
|
|
{party_name: [float * k]} — k = 50 for the canonical 2025 window |
|
|
|
|
""" |
|
|
|
|
try: |
|
|
|
|
con = duckdb.connect(database=db_path, read_only=True) |
|
|
|
|
placeholders = ", ".join("?" for _ in CURRENT_PARLIAMENT_PARTIES) |
|
|
|
|
rows = con.execute( |
|
|
|
|
f"SELECT entity_id, vector FROM svd_vectors " |
|
|
|
|
f"WHERE entity_type='mp' AND window_id='2025' " |
|
|
|
|
f"AND entity_id IN ({placeholders})", |
|
|
|
|
list(CURRENT_PARLIAMENT_PARTIES), |
|
|
|
|
).fetchall() |
|
|
|
|
con.close() |
|
|
|
|
return { |
|
|
|
|
row[0]: json.loads(row[1]) if isinstance(row[1], str) else list(row[1]) |
|
|
|
|
for row in rows |
|
|
|
|
} |
|
|
|
|
except Exception: |
|
|
|
|
logger.exception("Failed to load party axis scores") |
|
|
|
|
return {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@st.cache_data(show_spinner="Moties laden…") |
|
|
|
|
def load_motions_df(db_path: str) -> pd.DataFrame: |
|
|
|
|
"""Load the full motions table as a pandas DataFrame (read-only).""" |
|
|
|
|
|