Jan Mühlnikel commited on
Commit
9dcd3f9
·
1 Parent(s): 57a5237

renamed utils to modules

Browse files
modules/__pycache__/crs_table.cpython-310.pyc ADDED
Binary file (1.21 kB). View file
 
modules/__pycache__/filter_modules.cpython-310.pyc ADDED
Binary file (997 Bytes). View file
 
modules/__pycache__/filter_projects.cpython-310.pyc ADDED
Binary file (979 Bytes). View file
 
modules/__pycache__/navbar.cpython-310.pyc ADDED
Binary file (652 Bytes). View file
 
modules/__pycache__/result_table.cpython-310.pyc ADDED
Binary file (1.41 kB). View file
 
modules/__pycache__/sdg_table.cpython-310.pyc ADDED
Binary file (1.19 kB). View file
 
modules/__pycache__/semantic_search.cpython-310.pyc ADDED
Binary file (1.03 kB). View file
 
modules/__pycache__/similarity_table.cpython-310.pyc ADDED
Binary file (1.41 kB). View file
 
modules/filter_modules.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+ def country_option(special_cases, country_names):
5
+ country_option = st.multiselect(
6
+ 'Country / Countries',
7
+ special_cases + country_names,
8
+ placeholder="Select"
9
+ )
10
+
11
+ return country_option
12
+
13
+ def orga_option(special_cases, orga_names):
14
+ orga_list = special_cases + [f"{v[0]} ({k})" for k, v in orga_names.items()]
15
+ orga_option = st.multiselect(
16
+ 'Development Bank / Organization',
17
+ orga_list,
18
+ placeholder="Select"
19
+ )
20
+
21
+ return orga_option
modules/navbar.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
6
+ # green: #48d47b
7
+ # blue: #0da2dc
8
+ # grey: #dadada
9
+
10
+ # giz colors https://www.giz.de/cdc/en/html/59638.html
11
+ # red: #c80f0f
12
+ # grey: #6f6f6f
13
+ # light_grey: #b2b2b2
14
+ # light_red: #eba1a3
15
+
16
+ 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")
modules/result_table.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ def show_table(data_df, similarities:list):
4
+ st.write("------------------")
5
+
6
+ st.dataframe(
7
+ data_df[["title_main", "orga_abbreviation", "client", "description_main", "country", "sgd_pred_code", "crs_3_code", "crs_5_code", "similarity"]],
8
+ use_container_width = True,
9
+ height = 35 + 35 * len(data_df),
10
+ column_config={
11
+ "orga_abbreviation": st.column_config.TextColumn(
12
+ "Organization",
13
+ help="If description not in English, description in other language provided",
14
+ disabled=True
15
+ ),
16
+ "client": st.column_config.TextColumn(
17
+ "Client",
18
+ help="Client organization of customer",
19
+ disabled=True
20
+ ),
21
+ "title_main": st.column_config.TextColumn(
22
+ "Title",
23
+ help="If title not in English, title in other language provided",
24
+ disabled=True
25
+ ),
26
+ "description_main": st.column_config.TextColumn(
27
+ "Description",
28
+ help="If description not in English, description in other language provided",
29
+ disabled=True
30
+ ),
31
+ "country": st.column_config.TextColumn(
32
+ "Country",
33
+ help="Country of project",
34
+ disabled=True
35
+ ),
36
+ "sgd_pred_code": st.column_config.TextColumn(
37
+ "SDG Prediction",
38
+ help="Prediction of SDG's",
39
+ disabled=True
40
+ ),
41
+ "crs_3_code": st.column_config.TextColumn(
42
+ "CRS 3",
43
+ help="CRS 3 code given by organization",
44
+ disabled=True
45
+ ),
46
+ "crs_5_code": st.column_config.TextColumn(
47
+ "CRS 5",
48
+ help="CRS 5 code given by organization",
49
+ disabled=True
50
+ ),
51
+ },
52
+ hide_index=True,
53
+ )
modules/semantic_search.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+ import faiss
3
+ import streamlit as st
4
+ from sentence_transformers import SentenceTransformer
5
+
6
+ def show_search(model, faiss_index, sentences):
7
+ query = st.text_input("Enter your search query:")
8
+
9
+ if query:
10
+ # Convert query to embedding
11
+ query_embedding = model.encode([query])[0].reshape(1, -1)
12
+
13
+ # Perform search
14
+ D, I = faiss_index.search(query_embedding, k=5) # Search for top 5 similar items
15
+
16
+ # Extract the sentences corresponding to the top indices
17
+ top_sentences = [sentences[i] for i in I[0]]
18
+
19
+ # Display results as a selection list
20
+ selected_sentence = st.selectbox("Top results:", top_sentences)
21
+
22
+ # Optionally, do something with the selected sentence
23
+ st.write("You selected:", selected_sentence)