File size: 817 Bytes
1ba6d9d
 
 
 
 
 
 
2b4ec25
 
119455d
 
 
 
1ba6d9d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import gradio as gr
#os is used to change the directory
import os
#spacy is used for the NER
import spacy
#pandas is used to read, edit, and write tabular data
import pandas as pd
pip install https://huggingface.co/spacy/en_core_web_sm/resolve/main/en_core_web_sm-any-py3-none-any.whl


# Using spacy.load().
import spacy

from collections import Counter
import en_core_web_sm
# spacy.cli.download("en_core_web_lg")
nlp = en_core_web_sm.load()


nlp = spacy.load("en_core_web_sm")
def ner(sentence):
  doc = nlp(sentence)
  ents = [(e.text, e.label_) for e in doc.ents]
  return ents

examples = [
    "where did Wandobire's laptop come from, was it africa or uganda?",
]


iface=gr.Interface(ner, gr.Textbox(placeholder="Enter sentence here..."), 
             gr.HighlightedText(), examples=examples)
iface.launch()