nermodel2 / app.py
Jinapa's picture
Update app.py
0806471
import gradio as gr
import os
os.system('python -m spacy download ja_core_news_sm')
import spacy
from spacy import displacy
nlp = spacy.load("ja_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()