ppsingh commited on
Commit
8f06cde
β€’
1 Parent(s): ed9d589

target check

Browse files
Files changed (1) hide show
  1. appStore/target.py +63 -62
appStore/target.py CHANGED
@@ -104,72 +104,73 @@ def target_display():
104
 
105
 
106
  hits = df[df['Target Label'] == 'TARGET']
107
- # hits['GHG Label'] = hits['GHG Label'].apply(lambda i: _lab_dict[i])
108
- range_val = min(5,len(hits))
109
- if range_val !=0:
110
- count_target = sum(hits['Target Label'] == 'TARGET')
111
- count_netzero = sum(hits['Netzero Label'] == 'NETZERO')
112
- count_ghg = sum(hits['GHG Label'] == 'GHG')
113
- count_economy = sum([True if 'Economy-wide' in x else False
114
- for x in hits['Sector Label']])
 
115
 
116
- # count_df = df['Target Label'].value_counts()
117
- # count_df = count_df.rename('count')
118
- # count_df = count_df.rename_axis('Target Label').reset_index()
119
- # count_df['Label_def'] = count_df['Target Label'].apply(lambda x: _lab_dict[x])
120
 
121
- # fig = px.bar(count_df, y="Label_def", x="count", orientation='h', height=200)
122
- c1, c2 = st.columns([1,1])
123
- with c1:
124
- st.write('**Target Paragraphs**: `{}`'.format(count_target))
125
- st.write('**NetZero Related Paragraphs**: `{}`'.format(count_netzero))
126
 
127
- # st.plotly_chart(fig,use_container_width= True)
128
 
129
- # count_netzero = sum(hits['Netzero Label'] == 'NETZERO')
130
- # count_ghg = sum(hits['GHG Label'] == 'LABEL_2')
131
- # count_economy = sum([True if 'Economy-wide' in x else False
132
- # for x in hits['Sector Label']])
133
- with c2:
134
- st.write('**GHG Related Paragraphs**: `{}`'.format(count_ghg))
135
- st.write('**Economy-wide Related Paragraphs**: `{}`'.format(count_economy))
136
- st.write('-------------------')
137
- hits = hits.sort_values(by=['Relevancy'], ascending=False)
138
- netzerohit = hits[hits['Netzero Label'] == 'NETZERO']
139
- if not netzerohit.empty:
140
- netzerohit = netzerohit.sort_values(by = ['Netzero Score'], ascending = False)
141
- # st.write('-------------------')
142
- # st.markdown("###### Netzero paragraph ######")
143
- st.write('**Netzero paragraph** `page {}`: {}'.format(netzerohit.iloc[0]['page'],
144
- netzerohit.iloc[0]['text'].replace("\n", " ")))
145
- st.write("")
146
- else:
147
- st.info("πŸ€” No Netzero paragraph found")
148
 
149
- # st.write("**Result {}** `page {}` (Relevancy Score: {:.2f})'".format(i+1,hits.iloc[i]['page'],hits.iloc[i]['Relevancy'])")
150
- st.write('-------------------')
151
- st.markdown("###### Top few Target Classified paragraph/text results ######")
152
- range_val = min(5,len(hits))
153
- for i in range(range_val):
154
- # the page number reflects the page that contains the main paragraph
155
- # according to split limit, the overlapping part can be on a separate page
156
- st.write('**Result {}** (Relevancy Score: {:.2f}): `page {}`, `Sector: {}`,\
157
- `GHG: {}`, `Adapt-Mitig :{}`'\
158
- .format(i+1,hits.iloc[i]['Relevancy'],
159
- hits.iloc[i]['page'], hits.iloc[i]['Sector Label'],
160
- hits.iloc[i]['GHG Label'],hits.iloc[i]['Adapt-Mitig Label']))
161
- st.write("\t Text: \t{}".format(hits.iloc[i]['text'].replace("\n", " ")))
162
- hits = hits.reset_index(drop =True)
163
- st.write('----------------')
164
- st.write('Explore the data')
165
- st.write(hits)
166
- df_xlsx = to_excel(df)
167
 
168
- with st.sidebar:
169
- st.write('-------------')
170
- st.download_button(label='πŸ“₯ Download Result',
171
- data=df_xlsx ,
172
- file_name= os.path.splitext(st.session_state['filename'])[0]+'.xlsx')
173
 
174
- else:
175
- st.info("πŸ€” No Targets found")
 
104
 
105
 
106
  hits = df[df['Target Label'] == 'TARGET']
107
+ st.table(hits)
108
+ # # hits['GHG Label'] = hits['GHG Label'].apply(lambda i: _lab_dict[i])
109
+ # range_val = min(5,len(hits))
110
+ # if range_val !=0:
111
+ # count_target = sum(hits['Target Label'] == 'TARGET')
112
+ # count_netzero = sum(hits['Netzero Label'] == 'NETZERO')
113
+ # count_ghg = sum(hits['GHG Label'] == 'GHG')
114
+ # count_economy = sum([True if 'Economy-wide' in x else False
115
+ # for x in hits['Sector Label']])
116
 
117
+ # # count_df = df['Target Label'].value_counts()
118
+ # # count_df = count_df.rename('count')
119
+ # # count_df = count_df.rename_axis('Target Label').reset_index()
120
+ # # count_df['Label_def'] = count_df['Target Label'].apply(lambda x: _lab_dict[x])
121
 
122
+ # # fig = px.bar(count_df, y="Label_def", x="count", orientation='h', height=200)
123
+ # c1, c2 = st.columns([1,1])
124
+ # with c1:
125
+ # st.write('**Target Paragraphs**: `{}`'.format(count_target))
126
+ # st.write('**NetZero Related Paragraphs**: `{}`'.format(count_netzero))
127
 
128
+ # # st.plotly_chart(fig,use_container_width= True)
129
 
130
+ # # count_netzero = sum(hits['Netzero Label'] == 'NETZERO')
131
+ # # count_ghg = sum(hits['GHG Label'] == 'LABEL_2')
132
+ # # count_economy = sum([True if 'Economy-wide' in x else False
133
+ # # for x in hits['Sector Label']])
134
+ # with c2:
135
+ # st.write('**GHG Related Paragraphs**: `{}`'.format(count_ghg))
136
+ # st.write('**Economy-wide Related Paragraphs**: `{}`'.format(count_economy))
137
+ # st.write('-------------------')
138
+ # hits = hits.sort_values(by=['Relevancy'], ascending=False)
139
+ # netzerohit = hits[hits['Netzero Label'] == 'NETZERO']
140
+ # if not netzerohit.empty:
141
+ # netzerohit = netzerohit.sort_values(by = ['Netzero Score'], ascending = False)
142
+ # # st.write('-------------------')
143
+ # # st.markdown("###### Netzero paragraph ######")
144
+ # st.write('**Netzero paragraph** `page {}`: {}'.format(netzerohit.iloc[0]['page'],
145
+ # netzerohit.iloc[0]['text'].replace("\n", " ")))
146
+ # st.write("")
147
+ # else:
148
+ # st.info("πŸ€” No Netzero paragraph found")
149
 
150
+ # # st.write("**Result {}** `page {}` (Relevancy Score: {:.2f})'".format(i+1,hits.iloc[i]['page'],hits.iloc[i]['Relevancy'])")
151
+ # st.write('-------------------')
152
+ # st.markdown("###### Top few Target Classified paragraph/text results ######")
153
+ # range_val = min(5,len(hits))
154
+ # for i in range(range_val):
155
+ # # the page number reflects the page that contains the main paragraph
156
+ # # according to split limit, the overlapping part can be on a separate page
157
+ # st.write('**Result {}** (Relevancy Score: {:.2f}): `page {}`, `Sector: {}`,\
158
+ # `GHG: {}`, `Adapt-Mitig :{}`'\
159
+ # .format(i+1,hits.iloc[i]['Relevancy'],
160
+ # hits.iloc[i]['page'], hits.iloc[i]['Sector Label'],
161
+ # hits.iloc[i]['GHG Label'],hits.iloc[i]['Adapt-Mitig Label']))
162
+ # st.write("\t Text: \t{}".format(hits.iloc[i]['text'].replace("\n", " ")))
163
+ # hits = hits.reset_index(drop =True)
164
+ # st.write('----------------')
165
+ # st.write('Explore the data')
166
+ # st.write(hits)
167
+ # df_xlsx = to_excel(df)
168
 
169
+ # with st.sidebar:
170
+ # st.write('-------------')
171
+ # st.download_button(label='πŸ“₯ Download Result',
172
+ # data=df_xlsx ,
173
+ # file_name= os.path.splitext(st.session_state['filename'])[0]+'.xlsx')
174
 
175
+ # else:
176
+ # st.info("πŸ€” No Targets found")