Spaces:
Runtime error
Runtime error
[ADD] add radio button to switch between examples and inputs
Browse files
app.py
CHANGED
@@ -146,47 +146,67 @@ See the [GitHub repo](https://github.com/rexarski/climate-plus) for more details
|
|
146 |
|
147 |
st.markdown("## Factchecking")
|
148 |
|
149 |
-
|
150 |
-
"
|
|
|
151 |
)
|
152 |
-
selected_row1 = df1[df1["example"] == ex1_selected]
|
153 |
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
selected_row1["
|
159 |
-
)
|
160 |
-
st.markdown(f"**Claim**: {ex_claim}")
|
161 |
-
st.markdown(f"**Evidence**: {ex_evidence}")
|
162 |
-
st.markdown(f"**Label**: {ex_label}")
|
163 |
-
st.markdown(
|
164 |
-
f'**Prediction**: {ex_pred} {get_pred_emoji(ex_label, ex_pred, mode="factcheck")}'
|
165 |
-
)
|
166 |
|
167 |
-
|
168 |
-
|
169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
|
171 |
st.markdown("---")
|
172 |
|
173 |
st.markdown("## TCFD disclosure classification")
|
174 |
|
175 |
-
|
176 |
-
|
|
|
|
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
|
|
|
|
|
181 |
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
f'**Prediction**: {ex_pred2} {get_pred_emoji(ex_label2, ex_pred2, mode="tcfd")}'
|
186 |
-
)
|
187 |
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
|
|
|
146 |
|
147 |
st.markdown("## Factchecking")
|
148 |
|
149 |
+
factchecking_demo = st.radio(
|
150 |
+
"What examples do you want to see?",
|
151 |
+
("Preloaded examples", "Custom examples"),
|
152 |
)
|
|
|
153 |
|
154 |
+
if factchecking_demo == "Preloaded examples":
|
155 |
+
ex1_selected = st.selectbox(
|
156 |
+
"Select a climate claim-evidence pair", df1["example"]
|
157 |
+
)
|
158 |
+
selected_row1 = df1[df1["example"] == ex1_selected]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
|
160 |
+
ex_claim = selected_row1["claim"].values[0]
|
161 |
+
ex_evidence = selected_row1["evidence"].values[0]
|
162 |
+
ex_label = selected_row1["label"].values[0]
|
163 |
+
ex_pred = factcheck(
|
164 |
+
selected_row1["claim"].values[0], selected_row1["evidence"].values[0]
|
165 |
+
)
|
166 |
+
st.markdown(f"**Claim**: {ex_claim}")
|
167 |
+
st.markdown(f"**Evidence**: {ex_evidence}")
|
168 |
+
st.markdown(f"**Label**: {ex_label}")
|
169 |
+
st.markdown(
|
170 |
+
f'**Prediction**: {ex_pred} {get_pred_emoji(ex_label, ex_pred, mode="factcheck")}'
|
171 |
+
)
|
172 |
+
else:
|
173 |
+
st.markdown("Or enter your own claim and evidence below:")
|
174 |
+
custom_claim = st.text_input(label="Enter your claim.")
|
175 |
+
custom_evidence = st.text_input(label="Enter your evidence.")
|
176 |
+
if custom_claim != "" and custom_evidence != "":
|
177 |
+
st.markdown(
|
178 |
+
f"**Prediction**: {factcheck(custom_claim, custom_evidence)}"
|
179 |
+
)
|
180 |
|
181 |
st.markdown("---")
|
182 |
|
183 |
st.markdown("## TCFD disclosure classification")
|
184 |
|
185 |
+
tcfd_demo = st.radio(
|
186 |
+
"What examples do you want to see?",
|
187 |
+
("Preloaded examples", "Custom examples"),
|
188 |
+
)
|
189 |
|
190 |
+
if tcfd_demo == "Preloaded examples":
|
191 |
+
ex2_selected = st.selectbox(
|
192 |
+
"Select a TCFD disclosure example", df2["example"]
|
193 |
+
)
|
194 |
+
selected_row2 = df2[df2["example"] == ex2_selected]
|
195 |
|
196 |
+
ex_text = selected_row2["text"].values[0]
|
197 |
+
ex_label2 = selected_row2["label"].values[0]
|
198 |
+
ex_pred2 = tcfd_classify(selected_row2["text"].values[0])
|
|
|
|
|
199 |
|
200 |
+
st.markdown(f"**Text**: {ex_text}")
|
201 |
+
st.markdown(f"**Label**: {ex_label2}")
|
202 |
+
st.markdown(
|
203 |
+
f'**Prediction**: {ex_pred2} {get_pred_emoji(ex_label2, ex_pred2, mode="tcfd")}'
|
204 |
+
)
|
205 |
+
else:
|
206 |
+
st.markdown(
|
207 |
+
"Or enter your own sentence to see if it belongs to any specific TCFD disclosure category:"
|
208 |
+
)
|
209 |
+
custom_text = st.text_input(label="Enter your text.")
|
210 |
+
if custom_text != "":
|
211 |
+
st.markdown(f"**Prediction**: {tcfd_classify(custom_text)}")
|
212 |
|