Jan Mühlnikel
commited on
Commit
·
ad2cbdd
1
Parent(s):
bbb4e78
data update
Browse files- functions/filter_projects.py +8 -3
- similarity_page.py +9 -3
functions/filter_projects.py
CHANGED
@@ -5,9 +5,13 @@ def contains_code(crs_codes, code_list):
|
|
5 |
codes = str(crs_codes).split(';')
|
6 |
return any(code in code_list for code in codes)
|
7 |
|
8 |
-
def filter_projects(df, crs3_list, crs5_list, sdg_str, country_code_list, orga_code_list,
|
|
|
|
|
|
|
|
|
9 |
# Check if filters where not all should be selected are empty
|
10 |
-
if crs3_list != [] or crs5_list != [] or sdg_str != "" or query != "":
|
11 |
|
12 |
# FILTER CRS
|
13 |
if crs3_list and not crs5_list:
|
@@ -35,11 +39,12 @@ def filter_projects(df, crs3_list, crs5_list, sdg_str, country_code_list, orga_c
|
|
35 |
df = df[df['orga_abbreviation'].isin(orga_code_list)]
|
36 |
|
37 |
# FILTER QUERY
|
|
|
38 |
if query != "" and len(df) > 0:
|
39 |
if len(df) < TOP_X_PROJECTS:
|
40 |
TOP_X_PROJECTS = len(df)
|
41 |
df = search(query, model, embeddings, df, TOP_X_PROJECTS)
|
42 |
-
|
43 |
|
44 |
|
45 |
return df
|
|
|
5 |
codes = str(crs_codes).split(';')
|
6 |
return any(code in code_list for code in codes)
|
7 |
|
8 |
+
def filter_projects(df, crs3_list, crs5_list, sdg_str, country_code_list, orga_code_list,
|
9 |
+
#query,
|
10 |
+
model,
|
11 |
+
#embeddings,
|
12 |
+
TOP_X_PROJECTS=30):
|
13 |
# Check if filters where not all should be selected are empty
|
14 |
+
if crs3_list != [] or crs5_list != [] or sdg_str != "": #or query != "":
|
15 |
|
16 |
# FILTER CRS
|
17 |
if crs3_list and not crs5_list:
|
|
|
39 |
df = df[df['orga_abbreviation'].isin(orga_code_list)]
|
40 |
|
41 |
# FILTER QUERY
|
42 |
+
"""
|
43 |
if query != "" and len(df) > 0:
|
44 |
if len(df) < TOP_X_PROJECTS:
|
45 |
TOP_X_PROJECTS = len(df)
|
46 |
df = search(query, model, embeddings, df, TOP_X_PROJECTS)
|
47 |
+
"""
|
48 |
|
49 |
|
50 |
return df
|
similarity_page.py
CHANGED
@@ -111,6 +111,7 @@ def load_model():
|
|
111 |
return model
|
112 |
|
113 |
# Load Embeddings
|
|
|
114 |
@st.cache_data
|
115 |
def load_embeddings_and_index():
|
116 |
# Load embeddings
|
@@ -119,7 +120,7 @@ def load_embeddings_and_index():
|
|
119 |
embeddings = stored_data["embeddings"]
|
120 |
|
121 |
return embeddings
|
122 |
-
|
123 |
|
124 |
# USE CACHE FUNCTIONS
|
125 |
sim_matrix = load_sim_matrix()
|
@@ -198,7 +199,7 @@ def show_multi_matching_page():
|
|
198 |
)
|
199 |
|
200 |
# SEARCH BOX
|
201 |
-
query = st.text_input("Search Query")
|
202 |
|
203 |
with col3:
|
204 |
# COUNTRY SELECTION
|
@@ -242,7 +243,11 @@ def show_multi_matching_page():
|
|
242 |
|
243 |
# FILTER DF WITH SELECTED FILTER OPTIONS
|
244 |
TOP_X_PROJECTS = 30
|
245 |
-
filtered_df = filter_projects(projects_df, crs3_list, crs5_list, sdg_str, country_code_list, orga_code_list,
|
|
|
|
|
|
|
|
|
246 |
if isinstance(filtered_df, pd.DataFrame) and len(filtered_df) != 0:
|
247 |
# FIND MATCHES
|
248 |
## If only same country checkbox i sactivated
|
@@ -312,6 +317,7 @@ def show_single_matching_page():
|
|
312 |
else:
|
313 |
search_list = title_search_list
|
314 |
|
|
|
315 |
project_option = st.selectbox(
|
316 |
label = 'Search for a project',
|
317 |
index = None,
|
|
|
111 |
return model
|
112 |
|
113 |
# Load Embeddings
|
114 |
+
"""
|
115 |
@st.cache_data
|
116 |
def load_embeddings_and_index():
|
117 |
# Load embeddings
|
|
|
120 |
embeddings = stored_data["embeddings"]
|
121 |
|
122 |
return embeddings
|
123 |
+
"""
|
124 |
|
125 |
# USE CACHE FUNCTIONS
|
126 |
sim_matrix = load_sim_matrix()
|
|
|
199 |
)
|
200 |
|
201 |
# SEARCH BOX
|
202 |
+
#query = st.text_input("Search Query")
|
203 |
|
204 |
with col3:
|
205 |
# COUNTRY SELECTION
|
|
|
243 |
|
244 |
# FILTER DF WITH SELECTED FILTER OPTIONS
|
245 |
TOP_X_PROJECTS = 30
|
246 |
+
filtered_df = filter_projects(projects_df, crs3_list, crs5_list, sdg_str, country_code_list, orga_code_list,
|
247 |
+
#query,
|
248 |
+
model,
|
249 |
+
#embeddings,
|
250 |
+
TOP_X_PROJECTS)
|
251 |
if isinstance(filtered_df, pd.DataFrame) and len(filtered_df) != 0:
|
252 |
# FIND MATCHES
|
253 |
## If only same country checkbox i sactivated
|
|
|
317 |
else:
|
318 |
search_list = title_search_list
|
319 |
|
320 |
+
|
321 |
project_option = st.selectbox(
|
322 |
label = 'Search for a project',
|
323 |
index = None,
|