|
import streamlit as st |
|
import json |
|
import os |
|
|
|
st.set_page_config(page_title = 'Climate Policy Analysis Assistant', |
|
initial_sidebar_state='expanded', layout="wide") |
|
|
|
import logging |
|
logging.getLogger().setLevel(logging.INFO) |
|
from utils.uploadAndExample import add_upload |
|
import appStore.doc_processing as processing |
|
import appStore.tapp as tapp_extraction |
|
import appStore.adapmit as adapmit |
|
import appStore.sector as sector |
|
import appStore.subtarget as subtarget |
|
import appStore.tapp_display as tapp_display |
|
from PIL import Image |
|
import pkg_resources |
|
installed_packages = pkg_resources.working_set |
|
|
|
|
|
with st.sidebar: |
|
|
|
|
|
choice = st.sidebar.radio(label = 'Select the Document', |
|
help = 'You can upload the document \ |
|
or else you can try a example document', |
|
options = ('Upload Document', 'Try Example'), |
|
horizontal = True) |
|
with(open('docStore/sample/files.json','r')) as json_file: |
|
files = json.load(json_file) |
|
add_upload(choice, files) |
|
|
|
with st.container(): |
|
st.markdown("<h2 style='text-align: center; color: black;'> Climate Policy Analysis Assistant </h2>", unsafe_allow_html=True) |
|
st.write(' ') |
|
|
|
with st.expander("ℹ️ - About this app", expanded=False): |
|
st.write( |
|
""" |
|
Climate Policy Analysis Assistant (CPo_droid) is an open-source\ |
|
digital tool which aims to assist policy analysts and \ |
|
other users in extracting and filtering \ |
|
information from public documents in context of Climate Change Commitments and Strategies. |
|
""") |
|
|
|
c1, c2, c3 = st.columns([12,1,10]) |
|
with c1: |
|
st.write('**Definitions**') |
|
|
|
st.caption(""" |
|
- **Target**: Targets are an intention to achieve a specific result, \ |
|
for example, to reduce GHG emissions to a specific level \ |
|
(a GHG target) or increase energy efficiency or renewable \ |
|
energy to a specific level (a non-GHG target), typically by \ |
|
a certain date. There are are 3 subclass of targets: |
|
- **Netzero**: Identifies if its Netzero Target or not. |
|
- **GHG Target**: GHG targets refer to contributions framed as targeted \ |
|
outcomes in GHG terms. |
|
- **NonGHG Target**: Targets/contributions framed in NOT GHG terms like energy efficiency, sectoral-target like Distribution of 100K electric stoves etc. |
|
- **Action**: Actions are an intention to implement specific means of \ |
|
achieving GHG reductions, usually in forms of concrete projects. |
|
- **Policies**: Policies are domestic planning documents \ |
|
such as policies, regulations or guidlines. |
|
- **Plans**: Plans are broader than specific policies or actions, such as a general intention \ |
|
to ‘improve efficiency’, ‘develop renewable energy’, etc. \ |
|
These terms come from the World Bank's NDC platform and WRI's publication. |
|
""") |
|
|
|
|
|
|
|
|
|
|
|
with c3: |
|
st.write(""" |
|
What Happens in background? |
|
|
|
|
|
|
|
- Step 1: Once the document is provided to app, it undergoes *Pre-processing*.\ |
|
In this step the document is broken into smaller paragraphs \ |
|
(based on word/sentence count). |
|
- Step 2: The paragraphs are fed to **TAPP(Target/Action/Policy/Plan multilabel) Classifier** which detects if |
|
the paragraph contains any *TAPP* related information or not. |
|
- Step 3: The paragraphs which are detected containing some TAPP \ |
|
related information are then fed to multiple classifier to enrich the |
|
Information Extraction. These classifiers inlcude: Sector Classifier, Adaptation & Mitigation Classsifier, Conditionality Classifier. |
|
|
|
""") |
|
|
|
list_ = "" |
|
for package in installed_packages: |
|
list_ = list_ + f"{package.key}=={package.version}\n" |
|
st.download_button('Download Requirements', list_, file_name='requirements.txt') |
|
|
|
st.write("") |
|
|
|
|
|
apps = [processing.app, tapp_extraction.app, adapmit.app, sector.app, subtarget.app] |
|
|
|
|
|
multiplier_val =1/len(apps) |
|
if st.button("Analyze Document"): |
|
prg = st.progress(0.0) |
|
for i,func in enumerate(apps): |
|
func() |
|
prg.progress((i+1)*multiplier_val) |
|
prg.empty() |
|
|
|
if 'key1' in st.session_state: |
|
tapp_display.targets() |
|
tapp_display.actions() |
|
tapp_display.policy() |
|
tapp_display.plans() |
|
with st.sidebar: |
|
topic = st.radio( |
|
"Which category you want to explore?", |
|
('Targets', 'Actions','Policy','Plans')) |
|
|
|
if topic == 'Targets': |
|
tapp_display.target_display() |
|
elif topic == 'Actions': |
|
tapp_display.action_display() |
|
elif topic == 'Policy': |
|
tapp_display.policy_display() |
|
elif topic == 'Plans': |
|
tapp_display.plans_display() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|