ppsingh commited on
Commit
bc992a7
1 Parent(s): e385524

Update appStore/tapp_display.py

Browse files
Files changed (1) hide show
  1. appStore/tapp_display.py +89 -0
appStore/tapp_display.py CHANGED
@@ -127,4 +127,93 @@ def action_display():
127
  st.info("🤔 No Actions Found")
128
 
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
 
 
127
  st.info("🤔 No Actions Found")
128
 
129
 
130
+
131
+ def policy():
132
+ if 'key1' in st.session_state:
133
+ df = st.session_state['key1'].copy()
134
+ df = df.drop(df.filter(regex='Score').columns, axis=1)
135
+ df = df[df.PolicyLabel==True].reset_index(drop=True)
136
+ df['keep'] = True
137
+ df.drop(columns = ['TargetLabel','ActionLabel','PlansLabel','GHGLabel','NetzeroLabel','NonGHGLabel'], inplace=True)
138
+ st.session_state['policy_hits'] = df
139
+
140
+ def policy_display():
141
+ if 'key1' in st.session_state:
142
+ st.caption(""" **{}** is splitted into **{}** paragraphs/text chunks."""\
143
+ .format(os.path.basename(st.session_state['filename']),
144
+ len(st.session_state['key0'])))
145
+
146
+ hits = st.session_state['policy_hits']
147
+ if len(hits) !=0:
148
+ # collecting some statistics
149
+ count_action = sum(hits['PolicyLabel'] == True)
150
+ count_mitigation = sum(hits['MitigationLabel'] == True)
151
+ count_adaptation = sum(hits['AdaptationLabel'] == True)
152
+
153
+
154
+ c1, c2 = st.columns([1,1])
155
+ with c1:
156
+ st.write('**Policy Related Paragraphs**: `{}`'.format(count_action))
157
+ st.write('**Mitigation Related Paragraphs**: `{}`'.format(count_mitigation))
158
+ with c2:
159
+ st.write('**Adaptation Related Paragraphs**: `{}`'.format(count_adaptation))
160
+ st.write('----------------')
161
+ st.markdown("<h4 style='text-align: left; color: black;'> Sectoral Policy Related Paragraphs Count </h4>", unsafe_allow_html=True)
162
+ cols = list(hits.columns)
163
+ sector_cols = list(set(cols) - {'PolicyLabel','MitigationLabel','AdaptationLabel','GHGLabel','NetzeroLabel','NonGHGLabel','text','keep','page'})
164
+ placeholder= []
165
+ for col in sector_cols:
166
+ placeholder.append({'Sector':col,'Count':sum(hits[col] == True)})
167
+ sector_df = pd.DataFrame.from_dict(placeholder)
168
+ fig = px.bar(sector_df, x='Sector', y='Count')
169
+ st.plotly_chart(fig,use_container_width= True)
170
+
171
+ st.dataframe(hits)
172
+ else:
173
+ st.info("🤔 No Policy Found")
174
+
175
+ def plans():
176
+ if 'key1' in st.session_state:
177
+ df = st.session_state['key1'].copy()
178
+ df = df.drop(df.filter(regex='Score').columns, axis=1)
179
+ df = df[df.PlansLabel==True].reset_index(drop=True)
180
+ df['keep'] = True
181
+ df.drop(columns = ['TargetLabel','PolicyLabel','ActionLabel','GHGLabel','NetzeroLabel','NonGHGLabel'], inplace=True)
182
+ st.session_state['plan_hits'] = df
183
+
184
+ def plans_display():
185
+ if 'key1' in st.session_state:
186
+ st.caption(""" **{}** is splitted into **{}** paragraphs/text chunks."""\
187
+ .format(os.path.basename(st.session_state['filename']),
188
+ len(st.session_state['key0'])))
189
+
190
+ hits = st.session_state['plan_hits']
191
+ if len(hits) !=0:
192
+ # collecting some statistics
193
+ count_action = sum(hits['PlansLabel'] == True)
194
+ count_mitigation = sum(hits['MitigationLabel'] == True)
195
+ count_adaptation = sum(hits['AdaptationLabel'] == True)
196
+
197
+
198
+ c1, c2 = st.columns([1,1])
199
+ with c1:
200
+ st.write('**Plans Related Paragraphs**: `{}`'.format(count_action))
201
+ st.write('**Mitigation Related Paragraphs**: `{}`'.format(count_mitigation))
202
+ with c2:
203
+ st.write('**Adaptation Related Paragraphs**: `{}`'.format(count_adaptation))
204
+ st.write('----------------')
205
+ st.markdown("<h4 style='text-align: left; color: black;'> Sectoral Plans Related Paragraphs Count </h4>", unsafe_allow_html=True)
206
+ cols = list(hits.columns)
207
+ sector_cols = list(set(cols) - {'PlanLabel','MitigationLabel','AdaptationLabel','GHGLabel','NetzeroLabel','NonGHGLabel','text','keep','page'})
208
+ placeholder= []
209
+ for col in sector_cols:
210
+ placeholder.append({'Sector':col,'Count':sum(hits[col] == True)})
211
+ sector_df = pd.DataFrame.from_dict(placeholder)
212
+ fig = px.bar(sector_df, x='Sector', y='Count')
213
+ st.plotly_chart(fig,use_container_width= True)
214
+
215
+ st.dataframe(hits)
216
+ else:
217
+ st.info("🤔 No Plans Found")
218
+
219