Update app.py
Browse files
app.py
CHANGED
@@ -1,36 +1,43 @@
|
|
1 |
-
import appStore.target as target_extraction
|
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 |
-
from PIL import Image
|
12 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
st.set_page_config(page_title = 'Climate Policy Intelligence',
|
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 |
-
|
|
|
|
|
25 |
|
26 |
with st.container():
|
27 |
-
st.markdown("<h2 style='text-align: center; color: black;'> Climate Policy
|
28 |
st.write(' ')
|
29 |
|
30 |
with st.expander("ℹ️ - About this app", expanded=False):
|
31 |
st.write(
|
32 |
"""
|
33 |
-
|
34 |
digital tool which aims to assist policy analysts and \
|
35 |
other users in extracting and filtering relevant \
|
36 |
information from public documents.
|
@@ -47,17 +54,11 @@ with st.expander("ℹ️ - About this app", expanded=False):
|
|
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
|
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':
|
58 |
-
- 'NON GHG
|
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 \
|
@@ -84,37 +85,17 @@ with st.expander("ℹ️ - About this app", expanded=False):
|
|
84 |
- Step 1: Once the document is provided to app, it undergoes *Pre-processing*.\
|
85 |
In this step the document is broken into smaller paragraphs \
|
86 |
(based on word/sentence count).
|
87 |
-
- Step 2: The paragraphs are fed to **Target Classifier** which detects if
|
88 |
-
the paragraph contains any *
|
89 |
-
- Step 3: The paragraphs which are detected containing some
|
90 |
related information are then fed to multiple classifier to enrich the
|
91 |
Information Extraction.
|
92 |
|
93 |
-
The Step 2 and 3 are repated then similarly for Action and Policies & Plans.
|
94 |
""")
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
-
st.write("")
|
97 |
-
apps = [processing.app, target_extraction.app, netzero.app, ghg.app,
|
98 |
-
policyaction.app, conditional.app, sector.app, adapmit.app,indicator.app]
|
99 |
-
|
100 |
-
multiplier_val =1/len(apps)
|
101 |
-
if st.button("Analyze Document"):
|
102 |
-
prg = st.progress(0.0)
|
103 |
-
for i,func in enumerate(apps):
|
104 |
-
func()
|
105 |
-
prg.progress((i+1)*multiplier_val)
|
106 |
-
|
107 |
-
|
108 |
-
if 'key1' in st.session_state:
|
109 |
-
with st.sidebar:
|
110 |
-
topic = st.radio(
|
111 |
-
"Which category you want to explore?",
|
112 |
-
('Target', 'Action', 'Policies/Plans'))
|
113 |
-
|
114 |
-
if topic == 'Target':
|
115 |
-
target_extraction.target_display()
|
116 |
-
elif topic == 'Action':
|
117 |
-
policyaction.action_display()
|
118 |
-
else:
|
119 |
-
policyaction.policy_display()
|
120 |
-
# st.write(st.session_state.key1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import json
|
3 |
+
import os
|
4 |
+
# shifted from below - this must be the first streamlit call; otherwise: problems
|
5 |
+
st.set_page_config(page_title = 'Climate Policy Analysis Assistant',
|
6 |
+
initial_sidebar_state='expanded', layout="wide")
|
7 |
+
|
8 |
+
import logging
|
9 |
+
logging.getLogger().setLevel(logging.INFO)
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
import pkg_resources
|
18 |
+
installed_packages = pkg_resources.working_set
|
19 |
|
|
|
|
|
20 |
|
21 |
with st.sidebar:
|
22 |
# upload and example doc
|
23 |
+
|
24 |
choice = st.sidebar.radio(label = 'Select the Document',
|
25 |
help = 'You can upload the document \
|
26 |
or else you can try a example document',
|
27 |
options = ('Upload Document', 'Try Example'),
|
28 |
horizontal = True)
|
29 |
+
with(open('docStore/sample/files.json','r')) as json_file:
|
30 |
+
files = json.load(json_file)
|
31 |
+
add_upload(choice, files)
|
32 |
|
33 |
with st.container():
|
34 |
+
st.markdown("<h2 style='text-align: center; color: black;'> Climate Policy Analysis Assistant: CPo_droid </h2>", unsafe_allow_html=True)
|
35 |
st.write(' ')
|
36 |
|
37 |
with st.expander("ℹ️ - About this app", expanded=False):
|
38 |
st.write(
|
39 |
"""
|
40 |
+
CPo_droid is an open-source\
|
41 |
digital tool which aims to assist policy analysts and \
|
42 |
other users in extracting and filtering relevant \
|
43 |
information from public documents.
|
|
|
54 |
not at specific Sector level but are applicable at economic \
|
55 |
wide scale.
|
56 |
- **Netzero**: Identifies if its Netzero Target or not.
|
57 |
+
- 'NET-ZERO target_labels' = ['T_Netzero','T_Netzero_C']
|
|
|
|
|
|
|
|
|
58 |
- **GHG Target**: GHG targets refer to contributions framed as targeted \
|
59 |
outcomes in GHG terms.
|
60 |
+
- 'GHG': ['T_Transport_Unc','T_Transport_C','T_Economy_C','T_Economy_Unc','T_Energy_C','T_Energy_Unc']
|
61 |
+
- 'NON GHG TARGET': ['T_Adaptation_Unc','T_Adaptation_C', 'T_Transport_O_Unc', 'T_Transport_O_C']
|
|
|
|
|
62 |
- **Conditionality**: An “unconditional contribution” is what countries \
|
63 |
could implement without any conditions and based on their own \
|
64 |
resources and capabilities. A “conditional contribution” is one \
|
|
|
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 fed to **TAPP(Target/Action/Policy/Plan multilabel) Classifier** which detects if
|
89 |
+
the paragraph contains any *TAPP* related information or not.
|
90 |
+
- Step 3: The paragraphs which are detected containing some TAPP \
|
91 |
related information are then fed to multiple classifier to enrich the
|
92 |
Information Extraction.
|
93 |
|
|
|
94 |
""")
|
95 |
+
|
96 |
+
list_ = ""
|
97 |
+
for package in installed_packages:
|
98 |
+
list_ = list_ + f"{package.key}=={package.version}\n"
|
99 |
+
st.download_button('Download Requirements', list_, file_name='requirements.txt')
|
100 |
|
101 |
+
st.write("")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|