nermodel2 / app.py
sky3r's picture
Create app.py
1da9a19
raw
history blame contribute delete
847 Bytes
import gradio as gr
import os
os.system('python -m spacy download ko_core_news_sm')
import spacy
from spacy import displacy
nlp = spacy.load("ko_core_news_sm")
def text_analysis(text):
doc = nlp(text)
html = displacy.render(doc, style="dep", page=True)
html = (
""
+ html
+ ""
)
pos_count = {
"char_count": len(text),
"token_count": 0,
}
pos_tokens = []
for token in doc:
pos_tokens.extend([(token.text, token.pos_), (" ", None)])
return pos_tokens, pos_count, html
demo = gr.Interface(
text_analysis,
gr.Textbox(placeholder="Enter sentence here..."),
["highlight", "json", "html"],
examples=[
["์•„๋ฆ„๋‹ค์šด ์ถ”์–ต๋“ค์€ ์–ธ์  ๊ฐ„ ์‚ฌ๋ผ์ง€๊ฒ ์ง€๋งŒ"],
["์ง€๊ธˆ์ด๋ผ๋„ ๋…ธ๋ž˜๋กœ ๋‚จ๊ธฐ๊ณ  ์‹ถ์–ด"],
],
)
demo.launch()