Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,21 @@
|
|
1 |
-
import
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
#os is used to change the directory
|
3 |
+
#spacy is used for the NER
|
4 |
+
import spacy
|
5 |
+
from spacy import displacy
|
6 |
+
import en_core_web_sm
|
7 |
+
|
8 |
+
|
9 |
+
nlp = spacy.load("en_core_web_sm")
|
10 |
+
def ner_spacy(sentence):
|
11 |
+
doc = nlp(sentence)
|
12 |
+
ents = [(e.text, e.label_) for e in doc.ents]
|
13 |
+
return ents
|
14 |
+
|
15 |
+
examples = [
|
16 |
+
"where did Wandobire's laptop come from, was it africa or uganda?",
|
17 |
+
]
|
18 |
+
|
19 |
+
|
20 |
+
gr.Interface(ner_spacy, gr.Textbox(placeholder="Enter sentence here..."),
|
21 |
+
gr.HighlightedText(), examples=examples).launch(share=True)
|