@ -1,10 +1,9 @@
""" Parlement Explorer — Streamlit data analysis app.
Four tabs :
1. Politiek Kompas — 2 D scatter of MPs / parties , window slider
Three tabs :
1. Politiek Kompas — 2 D scatter of MPs / parties , window slider
2. Partij Trajectories — party centroid lines over time
3. Motie Zoeken — text search + similarity lookup
4. Motie Browser — sortable table + detail panel
3. SVD Components — component themes , scree plot , party positions
Run with : streamlit run explorer . py
@ -408,49 +407,6 @@ def load_motions_df(db_path: str) -> pd.DataFrame:
return explorer_data . load_motions_df ( db_path )
def query_similar (
db_path : str ,
source_motion_id : int ,
vector_type : str = " fused " ,
top_k : int = 10 ,
) - > pd . DataFrame :
""" Return top-k similar motions from similarity_cache (read-only). """
return explorer_data . query_similar ( db_path , source_motion_id , vector_type , top_k )
def _window_to_dates ( window_id : str ) - > tuple [ str , str ] :
""" Return (start_date, end_date) ISO strings for a given window_id. """
return trajectory . window_to_dates ( window_id )
def build_compass_tab ( * args , * * kwargs ) :
""" Build the Politiek Kompas tab. """
from analysis . tabs . compass import build_compass_tab as _impl
return _impl ( * args , * * kwargs )
def build_trajectories_tab ( * args , * * kwargs ) :
""" Build the Partij Trajectories tab. """
from analysis . tabs . trajectories import build_trajectories_tab as _impl
return _impl ( * args , * * kwargs )
def build_search_tab ( * args , * * kwargs ) :
""" Build the Motie Zoeken tab. """
from analysis . tabs . search import build_search_tab as _impl
return _impl ( * args , * * kwargs )
def build_browser_tab ( * args , * * kwargs ) :
""" Build the Motie Browser tab. """
from analysis . tabs . browser import build_browser_tab as _impl
return _impl ( * args , * * kwargs )
def build_svd_components_tab ( * args , * * kwargs ) :
""" Build the SVD Components tab. """
from analysis . tabs . components import build_svd_components_tab as _impl
@ -476,24 +432,16 @@ def run_app() -> None:
st . sidebar . title ( " Instellingen " )
db_path = " data/motions.db "
window_size = " annual "
show_rejected = st . sidebar . checkbox ( " Toon verworpen moties " , value = False )
with st . sidebar . expander ( " ℹ️ Over " , expanded = False ) :
try :
if _DUCKDB_AVAILABLE :
con = duckdb . connect ( database = db_path , read_only = True )
n_motions = con . execute ( " SELECT COUNT(*) FROM motions " ) . fetchone ( ) [ 0 ]
n_fused = con . execute (
" SELECT COUNT(*) FROM fused_embeddings "
) . fetchone ( ) [ 0 ]
n_sim = con . execute ( " SELECT COUNT(*) FROM similarity_cache " ) . fetchone ( ) [
0
]
con . close ( )
st . markdown (
f " **Moties:** { n_motions : , } \n "
f " **Fused embeddings:** { n_fused : , } \n "
f " **Similarity cache:** { n_sim : , } "
f " **Vensters:** per jaar + huidig parlement "
)
else :
st . warning (
@ -505,22 +453,16 @@ def run_app() -> None:
tab_labels = [
" 🧭 Politiek Kompas " ,
" 📈 Trajectories " ,
" 🔍 Motie Zoeken " ,
" 📋 Motie Browser " ,
" 🔬 SVD Components " ,
]
if hasattr ( st , " tabs " ) and callable ( getattr ( st , " tabs " ) ) :
tab1 , tab2 , tab3 , tab4 , tab5 = st . tabs ( tab_labels )
tab1 , tab2 , tab3 = st . tabs ( tab_labels )
with tab1 :
build_compass_tab ( db_path , window_size )
with tab2 :
build_trajectories_tab ( db_path , window_size )
with tab3 :
build_search_tab ( db_path , show_rejected )
with tab4 :
build_browser_tab ( db_path , show_rejected )
with tab5 :
build_svd_components_tab ( db_path )
else :
selection = st . radio ( " Tab " , tab_labels )
@ -528,10 +470,6 @@ def run_app() -> None:
build_compass_tab ( db_path , window_size )
elif selection == tab_labels [ 1 ] :
build_trajectories_tab ( db_path , window_size )
elif selection == tab_labels [ 2 ] :
build_search_tab ( db_path , show_rejected )
elif selection == tab_labels [ 3 ] :
build_browser_tab ( db_path , show_rejected )
else :
build_svd_components_tab ( db_path )