kleinay commited on
Commit
a3d296b
1 Parent(s): 45df43f

first commit

Browse files
Files changed (2) hide show
  1. app.py +32 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import nltk
3
+ nltk.download('omw-1.4')
4
+ from qanom.nominalization_detector import NominalizationDetector
5
+
6
+ detector = NominalizationDetector()
7
+
8
+ title = "Nominalization Detection Demo"
9
+ description = f"""This is a demo of QANom's nominalization detection algorithm,
10
+ comprised of candidate nominalization extraction followed by a contextualized binary classification model."""
11
+ links = """<p style='text-align: center'>
12
+ <a href='https://github.com/kleinay/QANom' target='_blank'>QANom repo</a> |
13
+ <a href='https://huggingface.co/kleinay/nominalization-candidate-classifier' target='_blank'>Model Repo at Huggingface Hub</a> |
14
+ <a href='https://www.aclweb.org/anthology/2020.coling-main.274/' target='_blank'>QANom Paper</a> |
15
+ </p>"""
16
+ examples = [["The doctor was interested in Luke 's treatment .", True, True, 0.6],
17
+ ["the construction of the officer 's building finished right after the beginning of the destruction of the previous construction .", True, True, 0.7]]
18
+
19
+ def call(sentence: str, return_all_candidates: bool, threshold: float):
20
+ ret = detector([sentence], return_all_candidates, True, threshold)[0]
21
+ return ret, ret
22
+
23
+ iface = gr.Interface(fn=call,
24
+ inputs=[gr.inputs.Textbox(label="Sentence", lines=3),
25
+ gr.inputs.Checkbox(default=True, label="Return all candidates?"),
26
+ gr.inputs.Slider(minimum=0., maximum=1., step=0.01, default=0.5, label="Threshold")],
27
+ outputs=[gr.outputs.JSON(label="Model Output"), gr.outputs.JSON(label="Model Output - QASRL")],
28
+ title=title,
29
+ description=description,
30
+ article=links,
31
+ examples=examples )
32
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
1
+ qanom>=0.0.11
2
+ torch