Update appStore/tapp_display.py
Browse files- appStore/tapp_display.py +60 -2
appStore/tapp_display.py
CHANGED
@@ -49,8 +49,8 @@ def target_display():
|
|
49 |
count_ghg = sum(hits['GHGLabel'] == True)
|
50 |
count_netzero = sum(hits['NetzeroLabel'] == True)
|
51 |
count_nonghg = sum(hits['NonGHGLabel'] == True)
|
52 |
-
|
53 |
-
|
54 |
|
55 |
|
56 |
c1, c2 = st.columns([1,1])
|
@@ -75,3 +75,61 @@ def target_display():
|
|
75 |
st.dataframe(hits)
|
76 |
else:
|
77 |
st.info("🤔 No Targets Found")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
count_ghg = sum(hits['GHGLabel'] == True)
|
50 |
count_netzero = sum(hits['NetzeroLabel'] == True)
|
51 |
count_nonghg = sum(hits['NonGHGLabel'] == True)
|
52 |
+
count_mitigation = sum(hits['MitigationLabel'] == True)
|
53 |
+
count_adaptation = sum(hits['AdaptationLabel'] == True)
|
54 |
|
55 |
|
56 |
c1, c2 = st.columns([1,1])
|
|
|
75 |
st.dataframe(hits)
|
76 |
else:
|
77 |
st.info("🤔 No Targets Found")
|
78 |
+
|
79 |
+
|
80 |
+
|
81 |
+
def targets():
|
82 |
+
if 'key1' in st.session_state:
|
83 |
+
df = st.session_state['key1'].copy()
|
84 |
+
idx = df['NetzeroLabel_Score'].idxmax()
|
85 |
+
netzero_placeholder = df.loc[idx, 'text']
|
86 |
+
df = df.drop(df.filter(regex='Score').columns, axis=1)
|
87 |
+
df = df[df.TargetLabel==True].reset_index(drop=True)
|
88 |
+
df['keep'] = True
|
89 |
+
df.drop(columns = ['ActionLabel','PolicyLabel','PlansLabel'], inplace=True)
|
90 |
+
st.session_state['target_hits'] = df
|
91 |
+
st.session_state['netzero'] = netzero_placeholder
|
92 |
+
|
93 |
+
def target_display():
|
94 |
+
if 'key1' in st.session_state:
|
95 |
+
st.caption(""" **{}** is splitted into **{}** paragraphs/text chunks."""\
|
96 |
+
.format(os.path.basename(st.session_state['filename']),
|
97 |
+
len(st.session_state['key0'])))
|
98 |
+
|
99 |
+
hits = st.session_state['target_hits']
|
100 |
+
if len(hits) !=0:
|
101 |
+
# collecting some statistics
|
102 |
+
count_target = sum(hits['TargetLabel'] == True)
|
103 |
+
count_ghg = sum(hits['GHGLabel'] == True)
|
104 |
+
count_netzero = sum(hits['NetzeroLabel'] == True)
|
105 |
+
count_nonghg = sum(hits['NonGHGLabel'] == True)
|
106 |
+
count_mitigation = sum(hits['MitigationLabel'] == True)
|
107 |
+
count_adaptation = sum(hits['AdaptationLabel'] == True)
|
108 |
+
|
109 |
+
|
110 |
+
c1, c2 = st.columns([1,1])
|
111 |
+
with c1:
|
112 |
+
st.write('**Target Related Paragraphs**: `{}`'.format(count_target))
|
113 |
+
st.write('**Netzero Related Paragraphs**: `{}`'.format(count_netzero))
|
114 |
+
st.write('**Mitigation Related Paragraphs**: `{}`'.format(count_mitigation))
|
115 |
+
with c2:
|
116 |
+
st.write('**GHG Target Related Paragraphs**: `{}`'.format(count_ghg))
|
117 |
+
st.write('**NonGHG Target Related Paragraphs**: `{}`'.format(count_nonghg))
|
118 |
+
st.write('**Adaptation Related Paragraphs**: `{}`'.format(count_adaptation))
|
119 |
+
st.write('----------------')
|
120 |
+
st.markdown("<h4 style='text-align: left; color: black;'> Sectoral Target Related Paragraphs Count </h4>", unsafe_allow_html=True)
|
121 |
+
cols = list(hits.columns)
|
122 |
+
sector_cols = list(set(cols) - {'TargetLabel','MitigationLabel','AdaptationLabel','GHGLabel','NetzeroLabel','NonGHGLabel','text','keep','page'})
|
123 |
+
placeholder= []
|
124 |
+
for col in sector_cols:
|
125 |
+
placeholder.append({'Sector':col,'Count':sum(hits[col] == True)})
|
126 |
+
sector_df = pd.DataFrame.from_dict(placeholder)
|
127 |
+
fig = px.bar(sector_df, x='Sector', y='Count')
|
128 |
+
st.plotly_chart(fig,use_container_width= True)
|
129 |
+
|
130 |
+
st.dataframe(hits)
|
131 |
+
else:
|
132 |
+
st.info("🤔 No Targets Found")
|
133 |
+
|
134 |
+
|
135 |
+
|