File size: 1,373 Bytes
6135ed9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b44c01
 
6135ed9
 
 
 
6b44c01
bf20079
 
 
 
3c07a5c
6135ed9
 
 
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
34
import gradio as gr
import os
os.system('python -m spacy download en_core_web_trf')
import spacy
from spacy import displacy

nlp = spacy.load("en_core_web_trf")

def ner(text):
    doc = nlp(text)
    html = displacy.render(doc, style="ent", page=True)
    # html = displacy.render(doc, style="ent", page=True, manual=True, minify=True)
    html = (
        "<div style='max-width:100%; max-height:360px; overflow:auto'>"
        + html
        + "</div>"
    )
    return html

title = "Named Entity Recognition"

demo = gr.Interface(
    ner,
    gr.Textbox(placeholder="Enter sentence here..."),
    outputs="html",
    title=title,
    examples=["In February 2006, Musk led Tesla's Series B venture capital funding round of $13 million, which added Valor Equity Partners to the funding team.[22][17] \
    Musk co-led the third, $40 million round in May 2006 which saw investment from prominent entrepreneurs including Google co-founders Sergey Brin and Larry Page, \
    and former eBay President Jeff Skoll.[23] A fourth round worth $45 million in May 2007 brought the total private financing investment to over $105 million.[23] \
    Tesla's first car, the Roadster, was officially revealed to the public on July 19, 2006, in Santa Monica, California, at a 350-person invitation-only event held \
    in Barker Hangar at Santa Monica Airport.[24]"]
)

demo.launch()