leavoigt commited on
Commit
31b5a19
1 Parent(s): 378d2da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +111 -7
app.py CHANGED
@@ -1,14 +1,118 @@
1
  import appStore.vulnerability_analysis as vulnerability_analysis
2
- import appStore.info as info
3
- from appStore.multiapp import MultiApp
 
 
 
 
 
 
 
 
4
  import streamlit as st
5
 
6
- st.set_page_config(page_title = 'Vulnerability Classifier',
7
  initial_sidebar_state='expanded', layout="wide")
8
 
9
- app = MultiApp()
 
 
 
 
 
 
 
10
 
11
- app.add_app("About","house", info.app)
12
- app.add_app("Vulnerability Analysis","gear", vulnerability_analysis.app)
 
13
 
14
- app.run()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import appStore.vulnerability_analysis as vulnerability_analysis
2
+ #import appStore.netzero as netzero
3
+ #import appStore.sector as sector
4
+ #import appStore.adapmit as adapmit
5
+ #import appStore.ghg as ghg
6
+ #import appStore.policyaction as policyaction
7
+ #import appStore.conditional as conditional
8
+ #import appStore.indicator as indicator
9
+ import appStore.doc_processing as processing
10
+ from utils.uploadAndExample import add_upload
11
+ #rom PIL import Image
12
  import streamlit as st
13
 
14
+ st.set_page_config(page_title = 'Vulnerability Analysis',
15
  initial_sidebar_state='expanded', layout="wide")
16
 
17
+ with st.sidebar:
18
+ # upload and example doc
19
+ choice = st.sidebar.radio(label = 'Select the Document',
20
+ help = 'You can upload the document \
21
+ or else you can try a example document',
22
+ options = ('Upload Document', 'Try Example'),
23
+ horizontal = True)
24
+ add_upload(choice)
25
 
26
+ with st.container():
27
+ st.markdown("<h2 style='text-align: center; color: black;'> Vulnerability Analysis </h2>", unsafe_allow_html=True)
28
+ st.write(' ')
29
 
30
+ with st.expander("ℹ️ - About this app", expanded=False):
31
+ st.write(
32
+ """
33
+ The Vulnerability Analysis App is an open-source\
34
+ digital tool which aims to assist policy analysts and \
35
+ other users in extracting and filtering relevant \
36
+ information related to different vulnerable groups from public documents.
37
+ """)
38
+ # st.write('**Definitions**')
39
+
40
+ # st.caption("""
41
+ # - **Target**: Targets are an intention to achieve a specific result, \
42
+ # for example, to reduce GHG emissions to a specific level \
43
+ # (a GHG target) or increase energy efficiency or renewable \
44
+ # energy to a specific level (a non-GHG target), typically by \
45
+ # a certain date.
46
+ # - **Economy-wide Target**: Certain Target are applicable \
47
+ # not at specific Sector level but are applicable at economic \
48
+ # wide scale.
49
+ # - **Netzero**: Identifies if its Netzero Target or not.
50
+ # - 'NET-ZERO': target_labels = ['T_Netzero','T_Netzero_C']
51
+ # - 'Non Netzero Target': target_labels_neg = ['T_Economy_C',
52
+ # 'T_Economy_Unc','T_Adaptation_C','T_Adaptation_Unc','T_Transport_C',
53
+ # 'T_Transport_O_C','T_Transport_O_Unc','T_Transport_Unc']
54
+ # - 'Others': Other Targets beside covered above
55
+ # - **GHG Target**: GHG targets refer to contributions framed as targeted \
56
+ # outcomes in GHG terms.
57
+ # - 'GHG': target_labels_ghg_yes = ['T_Transport_Unc','T_Transport_C']
58
+ # - 'NON GHG TRANSPORT TARGET': target_labels_ghg_no = ['T_Adaptation_Unc',\
59
+ # 'T_Adaptation_C', 'T_Transport_O_Unc', 'T_Transport_O_C']
60
+ # - 'OTHERS': Other Targets beside covered above.
61
+ # - **Conditionality**: An “unconditional contribution” is what countries \
62
+ # could implement without any conditions and based on their own \
63
+ # resources and capabilities. A “conditional contribution” is one \
64
+ # that countries would undertake if international means of support \
65
+ # are provided, or other conditions are met.
66
+ # - **Action**: Actions are an intention to implement specific means of \
67
+ # achieving GHG reductions, usually in forms of concrete projects.
68
+ # - **Policies and Plans**: Policies are domestic planning documents \
69
+ # such as policies, regulations or guidlines, and Plans are broader \
70
+ # than specific policies or actions, such as a general intention \
71
+ # to ‘improve efficiency’, ‘develop renewable energy’, etc. \
72
+ # The terms come from the World Bank's NDC platform and WRI's publication.
73
+ # """)
74
+
75
+ #c1, c2, c3 = st.columns([12,1,10])
76
+ #with c1:
77
+ # image = Image.open('docStore/img/flow.jpg')
78
+ # st.image(image)
79
+ #with c3:
80
+ st.write("""
81
+ What Happens in background?
82
+
83
+
84
+
85
+ - Step 1: Once the document is provided to app, it undergoes *Pre-processing*.\
86
+ In this step the document is broken into smaller paragraphs \
87
+ (based on word/sentence count).
88
+ - Step 2: The paragraphs are then fed to the **Vulnerability Classifier** which detects if
89
+ the paragraph contains any *Target* related information or not.
90
+ - Step 3: The paragraphs which are detected containing some reference \
91
+ to a vulnerable group are then fed to multiple classifier to enrich the
92
+ Information Extraction.
93
+ """)
94
+
95
+ st.write("")
96
+ apps = [vulnerability_analysis.app]
97
+
98
+ multiplier_val =1/len(apps)
99
+ if st.button("Analyze Document"):
100
+ prg = st.progress(0.0)
101
+ for i,func in enumerate(apps):
102
+ func()
103
+ prg.progress((i+1)*multiplier_val)
104
+
105
+
106
+ if 'key1' in st.session_state:
107
+ with st.sidebar:
108
+ topic = st.radio(
109
+ "Which category you want to explore?",
110
+ ('Vulnerability')
111
+
112
+ if topic == 'Vulnerability':
113
+ target_extraction.vulnerability_display()
114
+ # elif topic == 'Action':
115
+ # policyaction.action_display()
116
+ # else:
117
+ # policyaction.policy_display()
118
+ st.write(st.session_state.key1)