spacyner / app.py
miyachun's picture
Update app.py
3d553d3
raw
history blame contribute delete
651 Bytes
import spacy
import gradio as gr
nlp = spacy.load(r"./model-last")
def ner(sentence):
doc = nlp(sentence)
ents = [(e.text, e.label_) for e in doc.ents]
return ents
title = "Spacy NER"
desc = "(GPE01)->臺北市、新北市、桃園市、臺中市、臺南市、高雄市。(GPE02)->新竹縣、苗栗縣、彰化縣、南投縣、雲林縣、嘉義縣、屏東縣、宜蘭縣、花蓮縣、臺東縣、澎湖縣、金門縣、連江縣。(GPE03)->基隆市、新竹市、嘉義市。"
demo = gr.Interface(fn=ner, inputs="text", title=title, description=desc, outputs = "text")
demo.launch()
if __name__ == "__main__":
demo.launch()