Spaces:
Running
Running
Commit
·
13e7831
1
Parent(s):
cd683ff
use ner and rel
Browse files
app.py
CHANGED
@@ -25,7 +25,6 @@ relations = {
|
|
25 |
]
|
26 |
}
|
27 |
|
28 |
-
# The sample sentence you want to highlight:
|
29 |
SAMPLE_TEXT = (
|
30 |
"The Jordan Home Visits Survey, Round II (HV), was carried out by UNHCR and the World Food "
|
31 |
"Programme between November 2013 and September 2014. Through in-home visits to Syrian refugee "
|
@@ -42,7 +41,7 @@ def highlight_text(text):
|
|
42 |
"start": ent["start"],
|
43 |
"end": ent["end"],
|
44 |
})
|
45 |
-
# 2) RE spans
|
46 |
for src, rels in relations.items():
|
47 |
for r in rels:
|
48 |
label = r["relation"]
|
@@ -57,16 +56,15 @@ def highlight_text(text):
|
|
57 |
|
58 |
with gr.Blocks() as demo:
|
59 |
gr.Markdown("## Data Use Detector\n"
|
60 |
-
"
|
61 |
-
|
62 |
txt_in = gr.Textbox(label="Input Text", lines=4, value=SAMPLE_TEXT)
|
63 |
-
btn = gr.Button("Highlight
|
64 |
txt_out = gr.HighlightedText(label="Annotated Entities")
|
65 |
-
|
|
|
66 |
btn.click(fn=highlight_text, inputs=txt_in, outputs=txt_out)
|
67 |
-
|
68 |
-
demo.load(fn=highlight_text, inputs=txt_in, outputs=txt_out)
|
69 |
-
|
70 |
gr.Markdown("""
|
71 |
**Legend**
|
72 |
- **named dataset** → Home Visits Survey
|
|
|
25 |
]
|
26 |
}
|
27 |
|
|
|
28 |
SAMPLE_TEXT = (
|
29 |
"The Jordan Home Visits Survey, Round II (HV), was carried out by UNHCR and the World Food "
|
30 |
"Programme between November 2013 and September 2014. Through in-home visits to Syrian refugee "
|
|
|
41 |
"start": ent["start"],
|
42 |
"end": ent["end"],
|
43 |
})
|
44 |
+
# 2) RE spans
|
45 |
for src, rels in relations.items():
|
46 |
for r in rels:
|
47 |
label = r["relation"]
|
|
|
56 |
|
57 |
with gr.Blocks() as demo:
|
58 |
gr.Markdown("## Data Use Detector\n"
|
59 |
+
"Click **Highlight** to run inference on the sample sentence.")
|
60 |
+
|
61 |
txt_in = gr.Textbox(label="Input Text", lines=4, value=SAMPLE_TEXT)
|
62 |
+
btn = gr.Button("Highlight")
|
63 |
txt_out = gr.HighlightedText(label="Annotated Entities")
|
64 |
+
|
65 |
+
# **Only** trigger on button click
|
66 |
btn.click(fn=highlight_text, inputs=txt_in, outputs=txt_out)
|
67 |
+
|
|
|
|
|
68 |
gr.Markdown("""
|
69 |
**Legend**
|
70 |
- **named dataset** → Home Visits Survey
|