Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Jan Mühlnikel
commited on
Commit
•
2788caf
1
Parent(s):
7823114
added a same orga filter
Browse files- similarity_page.py +14 -1
similarity_page.py
CHANGED
@@ -31,6 +31,13 @@ def load_sim_matrix():
|
|
31 |
|
32 |
return dense_matrix
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
# Load Projects DFs
|
35 |
@st.cache_data
|
36 |
def load_projects():
|
@@ -110,6 +117,7 @@ def load_embeddings_and_index():
|
|
110 |
|
111 |
# USE CACHE FUNCTIONS
|
112 |
sim_matrix = load_sim_matrix()
|
|
|
113 |
projects_df = load_projects()
|
114 |
|
115 |
CRS3_MERGED = getCRS3()
|
@@ -160,6 +168,7 @@ def show_page():
|
|
160 |
options = SDG_NAMES[:-1],
|
161 |
)
|
162 |
|
|
|
163 |
|
164 |
with col2:
|
165 |
# COUNTRY SELECTION
|
@@ -209,7 +218,11 @@ def show_page():
|
|
209 |
#searched_filtered_df = semantic_search.show_search(model, embeddings, sentences, filtered_df, TOP_X_PROJECTS)
|
210 |
|
211 |
# FIND MATCHES
|
212 |
-
|
|
|
|
|
|
|
|
|
213 |
|
214 |
# SHOW THE RESULT
|
215 |
show_table(p1_df, p2_df)
|
|
|
31 |
|
32 |
return dense_matrix
|
33 |
|
34 |
+
@st.cache_data
|
35 |
+
def load_nonsameorga_sim_matrix():
|
36 |
+
loaded_matrix = load_npz("src/extended_similarities_nonsimorga.npz")
|
37 |
+
dense_matrix = loaded_matrix.toarray()
|
38 |
+
|
39 |
+
return dense_matrix
|
40 |
+
|
41 |
# Load Projects DFs
|
42 |
@st.cache_data
|
43 |
def load_projects():
|
|
|
117 |
|
118 |
# USE CACHE FUNCTIONS
|
119 |
sim_matrix = load_sim_matrix()
|
120 |
+
nonsameorgas_sim_matrix = load_nonsameorga_sim_matrix()
|
121 |
projects_df = load_projects()
|
122 |
|
123 |
CRS3_MERGED = getCRS3()
|
|
|
168 |
options = SDG_NAMES[:-1],
|
169 |
)
|
170 |
|
171 |
+
different_orga_checkbox = st.checkbox("Only matches between different organizations")
|
172 |
|
173 |
with col2:
|
174 |
# COUNTRY SELECTION
|
|
|
218 |
#searched_filtered_df = semantic_search.show_search(model, embeddings, sentences, filtered_df, TOP_X_PROJECTS)
|
219 |
|
220 |
# FIND MATCHES
|
221 |
+
if different_orga_checkbox:
|
222 |
+
p1_df, p2_df = calc_matches(filtered_df, projects_df, nonsameorgas_sim_matrix, TOP_X_PROJECTS)
|
223 |
+
|
224 |
+
else:
|
225 |
+
p1_df, p2_df = calc_matches(filtered_df, projects_df, sim_matrix, TOP_X_PROJECTS)
|
226 |
|
227 |
# SHOW THE RESULT
|
228 |
show_table(p1_df, p2_df)
|