Spaces:
GIZ
/
Running on CPU Upgrade

prashant commited on
Commit
6071464
1 Parent(s): bfc97d3

chaging keyword radio to checkbox

Browse files
appStore/info.py CHANGED
@@ -7,7 +7,7 @@ def app():
7
  st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
8
 
9
  st.markdown("<h2 style='text-align: center; \
10
- color: black;'> Policy Action Tracker Manual</h2>",
11
  unsafe_allow_html=True)
12
 
13
 
@@ -79,12 +79,6 @@ def app():
79
  consequence, the open-source web application aims to support the process\
80
  through suitable AI-powered and NLP methods. In the following, the \
81
  application’s functionalities are explained in more detail.
82
- <ul>
83
- <li>Analizing the policy document</li>
84
- <li>finding SDG related content</li>
85
- <li>Make it searchable</li>
86
- <li>compare it to the national NDC</li>
87
- </ul>
88
  </div>
89
  <br>
90
  """
 
7
  st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
8
 
9
  st.markdown("<h2 style='text-align: center; \
10
+ color: black;'> Climate Policy Action Tracker Manual</h2>",
11
  unsafe_allow_html=True)
12
 
13
 
 
79
  consequence, the open-source web application aims to support the process\
80
  through suitable AI-powered and NLP methods. In the following, the \
81
  application’s functionalities are explained in more detail.
 
 
 
 
 
 
82
  </div>
83
  <br>
84
  """
appStore/keyword_search.py CHANGED
@@ -8,6 +8,7 @@ import logging
8
  from utils.lexical_search import runLexicalPreprocessingPipeline, lexical_search
9
  from utils.semantic_search import runSemanticPreprocessingPipeline, semantic_keywordsearch
10
  from utils.checkconfig import getconfig
 
11
 
12
  # Declare all the necessary variables
13
  config = getconfig('paramconfig.cfg')
@@ -44,7 +45,7 @@ def app():
44
 
45
  st.write(
46
  """
47
- The *Keyword Search* app is an easy-to-use interface \
48
  built in Streamlit for doing keyword search in \
49
  policy document - developed by GIZ Data and the \
50
  Sustainable Development Solution Network.
@@ -60,8 +61,8 @@ def app():
60
  allows for a personalized experience in using the application. Both \
61
  methods employ a probabilistic retrieval framework in its identification\
62
  of relevant paragraphs. By defualt the search is performed using \
63
- 'Semantic Search' to find 'Exact/Lexical Matches' please tick the \
64
- checkbox provided, which will by pass semantic search.. Furthermore,\
65
  the application allows the user to search for pre-defined keywords \
66
  from different thematic buckets present in sidebar.""")
67
 
@@ -70,7 +71,8 @@ def app():
70
  with open('docStore/sample/keywordexample.json','r') as json_file:
71
  keywordexample = json.load(json_file)
72
 
73
- genre = st.radio("Select Keyword Category", list(keywordexample.keys()))
 
74
  if genre:
75
  keywordList = keywordexample[genre]
76
  else:
@@ -87,8 +89,8 @@ def app():
87
  will look for an answer in the document\
88
  OR enter the keyword you are looking \
89
  for and we will we will look for similar\
90
- context in the document. You can select the \
91
- presets of keywords from sidebar.",
92
  value = "{}".format(keywordList))
93
  searchtype = st.checkbox("Show only Exact Matches")
94
  if st.button("Find them"):
 
8
  from utils.lexical_search import runLexicalPreprocessingPipeline, lexical_search
9
  from utils.semantic_search import runSemanticPreprocessingPipeline, semantic_keywordsearch
10
  from utils.checkconfig import getconfig
11
+ from utils.streamlitcheck import checkbox_without_preselect
12
 
13
  # Declare all the necessary variables
14
  config = getconfig('paramconfig.cfg')
 
45
 
46
  st.write(
47
  """
48
+ The *Keyword Search* app is an easy-to-use interface \
49
  built in Streamlit for doing keyword search in \
50
  policy document - developed by GIZ Data and the \
51
  Sustainable Development Solution Network.
 
61
  allows for a personalized experience in using the application. Both \
62
  methods employ a probabilistic retrieval framework in its identification\
63
  of relevant paragraphs. By defualt the search is performed using \
64
+ 'Semantic Search', and to find 'Exact/Lexical Matches' please tick the \
65
+ checkbox provided, which will by-pass semantic search. Furthermore,\
66
  the application allows the user to search for pre-defined keywords \
67
  from different thematic buckets present in sidebar.""")
68
 
 
71
  with open('docStore/sample/keywordexample.json','r') as json_file:
72
  keywordexample = json.load(json_file)
73
 
74
+ # genre = st.radio("Select Keyword Category", list(keywordexample.keys()))
75
+ genre = checkbox_without_preselect(list(keywordexample.keys()))
76
  if genre:
77
  keywordList = keywordexample[genre]
78
  else:
 
89
  will look for an answer in the document\
90
  OR enter the keyword you are looking \
91
  for and we will we will look for similar\
92
+ context in the document. If dont have anything\
93
+ try the presets of keywords from sidebar. ",
94
  value = "{}".format(keywordList))
95
  searchtype = st.checkbox("Show only Exact Matches")
96
  if st.button("Find them"):
appStore/sdg_analysis.py CHANGED
@@ -75,9 +75,9 @@ def app():
75
  paragraphs with a calculated relevancy score above 85%. \n""")
76
 
77
  st.write("""**Keyphrase Extraction:** The application extracts 15 \
78
- keyphrases from the document, calculates a respective relevancy \
79
- score, and displays the results in a summary table. The keyphrases \
80
- are extracted using using [Textrank](https://github.com/summanlp/textrank)\
81
  which is an easy-to-use computational less expensive \
82
  model leveraging combination of TFIDF and Graph networks.
83
  """)
 
75
  paragraphs with a calculated relevancy score above 85%. \n""")
76
 
77
  st.write("""**Keyphrase Extraction:** The application extracts 15 \
78
+ keyphrases from the document, for each SDG label and displays the \
79
+ results in a summary table. The keyphrases are extracted using \
80
+ using [Textrank](https://github.com/summanlp/textrank)\
81
  which is an easy-to-use computational less expensive \
82
  model leveraging combination of TFIDF and Graph networks.
83
  """)
utils/streamlitcheck.py CHANGED
@@ -1,3 +1,10 @@
 
 
 
 
 
 
 
1
  def check_streamlit():
2
  """
3
  Function to check whether python code is run within streamlit
@@ -17,3 +24,19 @@ def check_streamlit():
17
  use_streamlit = False
18
  return use_streamlit
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ try:
3
+ import streamlit as st
4
+ except ImportError:
5
+ logging.info("Streamlit not installed")
6
+
7
+
8
  def check_streamlit():
9
  """
10
  Function to check whether python code is run within streamlit
 
24
  use_streamlit = False
25
  return use_streamlit
26
 
27
+ def disable_other_checkboxes(*other_checkboxes_keys):
28
+ for checkbox_key in other_checkboxes_keys:
29
+ st.session_state[checkbox_key] = False
30
+
31
+ def checkbox_without_preselect(keylist):
32
+ dict_ = {}
33
+ for i,key_val in enumerate(keylist):
34
+ dict_[i] = st.checkbox(key_val,key = key_val,
35
+ on_change = disable_other_checkboxes,
36
+ args=tuple(list(filter(lambda x: x!= key_val, keylist))),)
37
+
38
+ for key,val in dict_:
39
+ if val == True:
40
+ return keylist[int(key)]
41
+
42
+ return None