annikwag commited on
Commit
6c2d0be
·
verified ·
1 Parent(s): 8fdd4c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -75,10 +75,23 @@ unique_country_names = sorted(country_name_mapping.keys()) # List of country na
75
  # Layout filters in columns
76
  col1, col2, col3 = st.columns([1, 1, 4])
77
 
 
78
  with col1:
79
  region_filter = st.selectbox("Region", ["All/Not allocated"] + sorted(unique_sub_regions)) # Display region names
 
 
 
 
 
 
 
 
 
 
80
  with col2:
81
- country_filter = st.selectbox("Country", ["All/Not allocated"] + unique_country_names) # Display country names
 
 
82
  with col3:
83
  current_year = datetime.now().year
84
  default_start_year = current_year - 5 # Default to 5 years ago
@@ -128,7 +141,6 @@ def filter_results(results, country_filter, region_filter, end_year_range):
128
 
129
  if button:
130
  # 1) Use a bigger limit so we get more than 10 results
131
- # We'll filter them first, then slice the top 10 from the filtered set.
132
  results = hybrid_search(client, var, collection_name, limit=300) # e.g., 100 or 200
133
 
134
  # results is a tuple: (semantic_results, lexical_results)
 
75
  # Layout filters in columns
76
  col1, col2, col3 = st.columns([1, 1, 4])
77
 
78
+ # Region filter
79
  with col1:
80
  region_filter = st.selectbox("Region", ["All/Not allocated"] + sorted(unique_sub_regions)) # Display region names
81
+
82
+ # Dynamically filter countries based on selected region
83
+ if region_filter == "All/Not allocated":
84
+ filtered_country_names = unique_country_names # Show all countries if no region is selected
85
+ else:
86
+ filtered_country_names = [
87
+ name for name, code in country_name_mapping.items() if iso_code_to_sub_region.get(code) == region_filter
88
+ ]
89
+
90
+ # Country filter
91
  with col2:
92
+ country_filter = st.selectbox("Country", ["All/Not allocated"] + filtered_country_names) # Display filtered country names
93
+
94
+ # Year range slider
95
  with col3:
96
  current_year = datetime.now().year
97
  default_start_year = current_year - 5 # Default to 5 years ago
 
141
 
142
  if button:
143
  # 1) Use a bigger limit so we get more than 10 results
 
144
  results = hybrid_search(client, var, collection_name, limit=300) # e.g., 100 or 200
145
 
146
  # results is a tuple: (semantic_results, lexical_results)