Jan Mühlnikel commited on
Commit
21b6daa
1 Parent(s): 6a85a81

added sigle matching page and search option

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
 
app.py CHANGED
@@ -11,5 +11,5 @@ import similarity_page
11
 
12
  # NAVBAR
13
  navbar = show_navbar()
14
- similarity_page.show_page()
15
 
 
11
 
12
  # NAVBAR
13
  navbar = show_navbar()
14
+ #similarity_page.show_multi_matching_page()
15
 
modules/__pycache__/navbar.cpython-310.pyc CHANGED
Binary files a/modules/__pycache__/navbar.cpython-310.pyc and b/modules/__pycache__/navbar.cpython-310.pyc differ
 
modules/navbar.py CHANGED
@@ -1,5 +1,6 @@
1
  import streamlit as st
2
  from streamlit_option_menu import option_menu # https://github.com/victoryhb/streamlit-option-menu
 
3
 
4
  # giz-dsc colors
5
  # orange: #e5b50d
@@ -17,3 +18,13 @@ def show_navbar():
17
  st.markdown("<h1 style='color: red;'>THIS APP IS WORK IN PROGRESS ...</h1>", unsafe_allow_html=True)
18
 
19
  st.title("Development Bank Synergy Mapper")
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from streamlit_option_menu import option_menu # https://github.com/victoryhb/streamlit-option-menu
3
+ import similarity_page
4
 
5
  # giz-dsc colors
6
  # orange: #e5b50d
 
18
  st.markdown("<h1 style='color: red;'>THIS APP IS WORK IN PROGRESS ...</h1>", unsafe_allow_html=True)
19
 
20
  st.title("Development Bank Synergy Mapper")
21
+ tab1, tab2 = st.tabs([
22
+ "🔍 Multi-Project Matching",
23
+ "🎯 Single-Project Matching"
24
+ ])
25
+
26
+ with tab1:
27
+ similarity_page.show_multi_matching_page()
28
+
29
+ with tab2:
30
+ similarity_page.show_single_matching_page()
similarity_page.py CHANGED
@@ -53,7 +53,10 @@ def load_projects():
53
  projects_df = pd.merge(projects_df, status_df, on='iati_id', how='inner')
54
  projects_df = pd.merge(projects_df, texts_df, on='iati_id', how='inner')
55
 
56
- return projects_df
 
 
 
57
 
58
  # Load CRS 3 data
59
  @st.cache_data
@@ -118,7 +121,7 @@ def load_embeddings_and_index():
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()
124
  CRS5_MERGED = getCRS5()
@@ -130,7 +133,7 @@ COUNTRY_OPTION_LIST = getCountry()
130
  model = load_model()
131
  embeddings = load_embeddings_and_index()
132
 
133
- def show_page():
134
  st.write(f"Current RAM usage of this app: {get_process_memory():.2f} MB")
135
  st.write("Similarities")
136
 
@@ -238,4 +241,28 @@ def show_page():
238
  st.write("Select at least on CRS 3, SDG or type in a query")
239
 
240
  del crs3_list, crs5_list, sdg_str, filtered_df
241
- gc.collect()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  projects_df = pd.merge(projects_df, status_df, on='iati_id', how='inner')
54
  projects_df = pd.merge(projects_df, texts_df, on='iati_id', how='inner')
55
 
56
+ iati_search_list = [f'{row.iati_id}' for row in projects_df.itertuples()]
57
+ title_search_list = [f'{row.title_main} ({row.orga_abbreviation.upper()})' for row in projects_df.itertuples()]
58
+
59
+ return projects_df, iati_search_list, title_search_list
60
 
61
  # Load CRS 3 data
62
  @st.cache_data
 
121
  # USE CACHE FUNCTIONS
122
  sim_matrix = load_sim_matrix()
123
  nonsameorgas_sim_matrix = load_nonsameorga_sim_matrix()
124
+ projects_df, iati_search_list, title_search_list = load_projects()
125
 
126
  CRS3_MERGED = getCRS3()
127
  CRS5_MERGED = getCRS5()
 
133
  model = load_model()
134
  embeddings = load_embeddings_and_index()
135
 
136
+ def show_multi_matching_page():
137
  st.write(f"Current RAM usage of this app: {get_process_memory():.2f} MB")
138
  st.write("Similarities")
139
 
 
241
  st.write("Select at least on CRS 3, SDG or type in a query")
242
 
243
  del crs3_list, crs5_list, sdg_str, filtered_df
244
+ gc.collect()
245
+
246
+
247
+
248
+ def show_single_matching_page():
249
+
250
+ search_option = st.selectbox(
251
+ label = 'Select how you want to search',
252
+ index = 0,
253
+ placeholder = " ",
254
+ options = ["Search with IATI ID", "Search with project title"],
255
+ )
256
+
257
+ if search_option == "Search with IATI ID":
258
+ search_list = iati_search_list
259
+ else:
260
+ search_list = title_search_list
261
+
262
+ project_option = st.selectbox(
263
+ label = 'Search for a project with the IATI ID or teh project title',
264
+ index = None,
265
+ placeholder = " ",
266
+ options = search_list,
267
+ )
268
+