Jan Mühlnikel
commited on
Commit
·
784ae4f
1
Parent(s):
83fabd0
rmv checkboxes
Browse files
__pycache__/similarity_page.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/similarity_page.cpython-310.pyc and b/__pycache__/similarity_page.cpython-310.pyc differ
|
|
|
functions/__pycache__/single_similar.cpython-310.pyc
CHANGED
|
Binary files a/functions/__pycache__/single_similar.cpython-310.pyc and b/functions/__pycache__/single_similar.cpython-310.pyc differ
|
|
|
functions/single_similar.py
CHANGED
|
@@ -3,7 +3,7 @@ import numpy as np
|
|
| 3 |
|
| 4 |
def find_similar(p_index, similarity_matrix, projects_df, top_x):
|
| 5 |
selected_row = similarity_matrix[p_index]
|
| 6 |
-
top_indexes = np.argsort(selected_row)[-
|
| 7 |
top_values = selected_row[top_indexes]
|
| 8 |
|
| 9 |
top_projects_df = projects_df.iloc[top_indexes]
|
|
|
|
| 3 |
|
| 4 |
def find_similar(p_index, similarity_matrix, projects_df, top_x):
|
| 5 |
selected_row = similarity_matrix[p_index]
|
| 6 |
+
top_indexes = np.argsort(selected_row)[-top_x:][::-1]
|
| 7 |
top_values = selected_row[top_indexes]
|
| 8 |
|
| 9 |
top_projects_df = projects_df.iloc[top_indexes]
|
modules/singlematch_result_table.py
CHANGED
|
@@ -3,81 +3,84 @@ import pandas as pd
|
|
| 3 |
|
| 4 |
def show_single_table(result_df):
|
| 5 |
|
| 6 |
-
result_df
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
|
|
|
| 3 |
|
| 4 |
def show_single_table(result_df):
|
| 5 |
|
| 6 |
+
if len(result_df) == 0:
|
| 7 |
+
st.write("No resuolts found!")
|
| 8 |
+
else:
|
| 9 |
+
result_df = result_df.reset_index(drop=True)
|
| 10 |
|
| 11 |
+
# Transformations
|
| 12 |
+
result_df["crs_3_code_list"] = result_df['crs_3_code'].str.split(";").apply(lambda x: x[:-1] if x else [])
|
| 13 |
+
result_df["crs_5_code_list"] = result_df['crs_5_code'].str.split(";").apply(lambda x: x[:-1] if x else [])
|
| 14 |
+
result_df["sdg_list"] = result_df['sgd_pred_code'].apply(lambda x: [x] if pd.notna(x) else [])
|
| 15 |
+
result_df["flag"] = result_df['country'].apply(lambda x: f"https://flagicons.lipis.dev/flags/4x3/{x[:2].lower()}.svg" if pd.notna(x) else "https://flagicons.lipis.dev/flags/4x3/xx.svg")
|
| 16 |
+
|
| 17 |
+
st.dataframe(
|
| 18 |
+
result_df[["similarity", "iati_id", "title_main", "orga_abbreviation", "client", "description_main", "country", "flag", "sdg_list", "crs_3_code_list", "crs_5_code_list"]],
|
| 19 |
+
use_container_width = True,
|
| 20 |
+
height = 35 + 35 * len(result_df),
|
| 21 |
+
column_config={
|
| 22 |
+
"similarity": st.column_config.TextColumn(
|
| 23 |
+
"Similarity",
|
| 24 |
+
help="similarity to selected project",
|
| 25 |
+
disabled=True,
|
| 26 |
+
width="small"
|
| 27 |
+
),
|
| 28 |
+
"iati_id": st.column_config.TextColumn(
|
| 29 |
+
"IATI ID",
|
| 30 |
+
help="IATI Project ID",
|
| 31 |
+
disabled=True,
|
| 32 |
+
width="small"
|
| 33 |
+
),
|
| 34 |
+
"orga_abbreviation": st.column_config.TextColumn(
|
| 35 |
+
"Organization",
|
| 36 |
+
help="If description not in English, description in other language provided",
|
| 37 |
+
disabled=True,
|
| 38 |
+
width="small"
|
| 39 |
+
),
|
| 40 |
+
"client": st.column_config.TextColumn(
|
| 41 |
+
"Client",
|
| 42 |
+
help="Client organization of customer",
|
| 43 |
+
disabled=True,
|
| 44 |
+
width="small"
|
| 45 |
+
),
|
| 46 |
+
"title_main": st.column_config.TextColumn(
|
| 47 |
+
"Title",
|
| 48 |
+
help="If title not in English, title in other language provided",
|
| 49 |
+
disabled=True,
|
| 50 |
+
width="large"
|
| 51 |
+
),
|
| 52 |
+
"description_main": st.column_config.TextColumn(
|
| 53 |
+
"Description",
|
| 54 |
+
help="If description not in English, description in other language provided",
|
| 55 |
+
disabled=True,
|
| 56 |
+
width="large"
|
| 57 |
+
),
|
| 58 |
+
"country": st.column_config.TextColumn(
|
| 59 |
+
"Country",
|
| 60 |
+
help="Country of project",
|
| 61 |
+
disabled=True,
|
| 62 |
+
width="small"
|
| 63 |
+
),
|
| 64 |
+
"flag": st.column_config.ImageColumn(
|
| 65 |
+
"Flag",
|
| 66 |
+
help="country flag",
|
| 67 |
+
width="small"
|
| 68 |
+
),
|
| 69 |
+
"sdg_list": st.column_config.ListColumn(
|
| 70 |
+
"SDG Prediction",
|
| 71 |
+
help="Prediction of SDG's",
|
| 72 |
+
width="small"
|
| 73 |
+
),
|
| 74 |
+
"crs_3_code_list": st.column_config.ListColumn(
|
| 75 |
+
"CRS 3",
|
| 76 |
+
help="CRS 3 code given by organization",
|
| 77 |
+
width="small"
|
| 78 |
+
),
|
| 79 |
+
"crs_5_code_list": st.column_config.ListColumn(
|
| 80 |
+
"CRS 5",
|
| 81 |
+
help="CRS 5 code given by organization",
|
| 82 |
+
width="small"
|
| 83 |
+
),
|
| 84 |
+
},
|
| 85 |
+
hide_index=True,
|
| 86 |
+
)
|
similarity_page.py
CHANGED
|
@@ -268,24 +268,26 @@ def show_single_matching_page():
|
|
| 268 |
options = search_list,
|
| 269 |
)
|
| 270 |
|
| 271 |
-
different_orga_checkbox_ = st.checkbox("Only matches for organisations other than the selected project")
|
| 272 |
-
filterd_country_only_checkbox_ = st.checkbox("Only matches in the same countries as project selection")
|
| 273 |
|
|
|
|
| 274 |
if project_option:
|
|
|
|
| 275 |
|
|
|
|
| 276 |
if filterd_country_only_checkbox_:
|
| 277 |
country = projects_df.iloc[selected_index]["country"]
|
| 278 |
same_country_df = projects_df[projects_df['country'] == country]
|
| 279 |
else:
|
| 280 |
same_country_df = projects_df
|
| 281 |
|
| 282 |
-
selected_index = search_list.index(project_option)
|
| 283 |
if different_orga_checkbox_:
|
| 284 |
orga = projects_df.iloc[selected_index]["orga_abbreviation"]
|
| 285 |
different_orga_df = same_country_df[same_country_df['orga_abbreviation'] != orga]
|
| 286 |
else:
|
| 287 |
different_orga_df = same_country_df
|
| 288 |
-
|
| 289 |
-
top_projects_df = find_similar(selected_index, sim_matrix,
|
| 290 |
show_single_table(top_projects_df)
|
| 291 |
|
|
|
|
| 268 |
options = search_list,
|
| 269 |
)
|
| 270 |
|
| 271 |
+
#different_orga_checkbox_ = st.checkbox("Only matches for organisations other than the selected project")
|
| 272 |
+
#filterd_country_only_checkbox_ = st.checkbox("Only matches in the same countries as project selection")
|
| 273 |
|
| 274 |
+
#selected_index = None
|
| 275 |
if project_option:
|
| 276 |
+
selected_index = search_list.index(project_option)
|
| 277 |
|
| 278 |
+
"""
|
| 279 |
if filterd_country_only_checkbox_:
|
| 280 |
country = projects_df.iloc[selected_index]["country"]
|
| 281 |
same_country_df = projects_df[projects_df['country'] == country]
|
| 282 |
else:
|
| 283 |
same_country_df = projects_df
|
| 284 |
|
|
|
|
| 285 |
if different_orga_checkbox_:
|
| 286 |
orga = projects_df.iloc[selected_index]["orga_abbreviation"]
|
| 287 |
different_orga_df = same_country_df[same_country_df['orga_abbreviation'] != orga]
|
| 288 |
else:
|
| 289 |
different_orga_df = same_country_df
|
| 290 |
+
"""
|
| 291 |
+
top_projects_df = find_similar(selected_index, sim_matrix, projects_df, 10)
|
| 292 |
show_single_table(top_projects_df)
|
| 293 |
|