Spaces:
Running
Running
Split option for files and improved description.
Browse files
app.py
CHANGED
@@ -242,12 +242,17 @@ async def framing_textbox(text, split, min_node_threshold):
|
|
242 |
return framing_multi(texts, min_node_threshold)
|
243 |
return framing_single(text, min_node_threshold)
|
244 |
|
245 |
-
async def framing_file(file_obj, min_node_threshold):
|
246 |
with open(file_obj.name, "r") as f:
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
|
|
|
|
|
|
|
|
|
|
251 |
|
252 |
example_list = [["In 2010, CFCs were banned internationally due to their harmful effect on the ozone layer.", False, 1],
|
253 |
["In 2021, doctors prevented the spread of the virus by vaccinating with Pfizer.", False, 1],
|
@@ -258,15 +263,20 @@ example_list = [["In 2010, CFCs were banned internationally due to their harmful
|
|
258 |
["I believe that we should act now.\nThere is no time to waste.", True, 1],
|
259 |
]
|
260 |
|
|
|
|
|
|
|
|
|
|
|
261 |
textbox_inferface = gr.Interface(fn=framing_textbox,
|
262 |
inputs=[
|
263 |
gr.Textbox(label="Text to analyze."),
|
264 |
gr.Checkbox(True, label="Split on newlines? (To enter newlines type shift+Enter)"),
|
265 |
gr.Number(1, label="Min node threshold for framing structure.")
|
266 |
],
|
267 |
-
description=
|
268 |
examples=example_list,
|
269 |
-
article=
|
270 |
outputs=[gr.Plot(label="Label"),
|
271 |
gr.Plot(label="Dimensions"),
|
272 |
gr.Plot(label="Structure")
|
@@ -275,10 +285,11 @@ textbox_inferface = gr.Interface(fn=framing_textbox,
|
|
275 |
file_interface = gr.Interface(fn=framing_file,
|
276 |
inputs=[
|
277 |
gr.File(label="File of texts to analyze."),
|
|
|
278 |
gr.Number(1, label="Min node threshold for framing structure."),
|
279 |
],
|
280 |
-
description=
|
281 |
-
article=
|
282 |
outputs=[gr.Plot(label="Label"),
|
283 |
gr.Plot(label="Dimensions"),
|
284 |
gr.Plot(label="Structure")])
|
|
|
242 |
return framing_multi(texts, min_node_threshold)
|
243 |
return framing_single(text, min_node_threshold)
|
244 |
|
245 |
+
async def framing_file(file_obj, split, min_node_threshold):
|
246 |
with open(file_obj.name, "r") as f:
|
247 |
+
if split:
|
248 |
+
texts = f.readlines()
|
249 |
+
if len(texts) > 1:
|
250 |
+
return framing_multi(texts, min_node_threshold)
|
251 |
+
else:
|
252 |
+
text = texts[0]
|
253 |
+
else:
|
254 |
+
text = f.read()
|
255 |
+
return framing_single(text, min_node_threshold)
|
256 |
|
257 |
example_list = [["In 2010, CFCs were banned internationally due to their harmful effect on the ozone layer.", False, 1],
|
258 |
["In 2021, doctors prevented the spread of the virus by vaccinating with Pfizer.", False, 1],
|
|
|
263 |
["I believe that we should act now.\nThere is no time to waste.", True, 1],
|
264 |
]
|
265 |
|
266 |
+
description = """A simple tool that helps you find (discover and detect) frames in text.
|
267 |
+
|
268 |
+
Note that due to the computation time required for underlying Transformer models, only short texts are recommended."""
|
269 |
+
article=""""Check out the preliminary article in the [Web Conference Symposium](https://dl.acm.org/doi/pdf/10.1145/3543873.3587534), will be updated to currently in review article after publication."""
|
270 |
+
|
271 |
textbox_inferface = gr.Interface(fn=framing_textbox,
|
272 |
inputs=[
|
273 |
gr.Textbox(label="Text to analyze."),
|
274 |
gr.Checkbox(True, label="Split on newlines? (To enter newlines type shift+Enter)"),
|
275 |
gr.Number(1, label="Min node threshold for framing structure.")
|
276 |
],
|
277 |
+
description=description,
|
278 |
examples=example_list,
|
279 |
+
article=article,
|
280 |
outputs=[gr.Plot(label="Label"),
|
281 |
gr.Plot(label="Dimensions"),
|
282 |
gr.Plot(label="Structure")
|
|
|
285 |
file_interface = gr.Interface(fn=framing_file,
|
286 |
inputs=[
|
287 |
gr.File(label="File of texts to analyze."),
|
288 |
+
gr.Checkbox(True, label="Split on newlines?"),
|
289 |
gr.Number(1, label="Min node threshold for framing structure."),
|
290 |
],
|
291 |
+
description=description,
|
292 |
+
article=article,
|
293 |
outputs=[gr.Plot(label="Label"),
|
294 |
gr.Plot(label="Dimensions"),
|
295 |
gr.Plot(label="Structure")])
|