brijw commited on
Commit
1ba6d9d
1 Parent(s): 52a213b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ #os is used to change the directory
3
+ import os
4
+ #spacy is used for the NER
5
+ import spacy
6
+ #pandas is used to read, edit, and write tabular data
7
+ import pandas as pd
8
+ from spacy import displacy
9
+ from collections import Counter
10
+ import en_core_web_sm
11
+ # spacy.cli.download("en_core_web_lg")
12
+ nlp = en_core_web_sm.load()
13
+
14
+
15
+ nlp = spacy.load("en_core_web_sm")
16
+ def ner(sentence):
17
+ doc = nlp(sentence)
18
+ ents = [(e.text, e.label_) for e in doc.ents]
19
+ return ents
20
+
21
+ examples = [
22
+ "where did Wandobire's laptop come from, was it africa or uganda?",
23
+ ]
24
+
25
+
26
+ iface=gr.Interface(ner, gr.Textbox(placeholder="Enter sentence here..."),
27
+ gr.HighlightedText(), examples=examples)
28
+ iface.launch()