tomofi commited on
Commit
914ca91
1 Parent(s): a61983e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ os.system('git clone --depth 1 https://github.com/neologd/mecab-ipadic-neologd.git && cd mecab-ipadic-neologd && ./bin/install-mecab-ipadic-neologd -n -y')
4
+
5
+ import streamlit as st
6
+
7
+ import MeCab
8
+
9
+ tagger = MeCab.Tagger('-r /etc/mecabrc -Ochasen -d /usr/lib/x86_64-linux-gnu/mecab/dic/mecab-ipadic-neologd')
10
+ st.set_page_config(page_title="NEologd demo")
11
+ st.title('NEologd demo')
12
+
13
+
14
+ """
15
+ Input the text you'd like to analyze. See the [NEologd][] docs for more details.
16
+ [NEologd]: https://github.com/neologd
17
+ """
18
+
19
+ text = st.text_area("input", "麩菓子は、麩を主材料とした日本の菓子。")
20
+
21
+ def make_row(word):
22
+ ff = word.feature.split(",")
23
+ return dict(surface=word.surface, kana=ff[7], lemma=ff[6],
24
+ pos1=ff[0], pos2=ff[1], pos3=ff[2], pos4=ff[3])
25
+
26
+ data = []
27
+
28
+ node = tagger.parseToNode(text)
29
+ while node:
30
+ if node.feature.startswith('BOS/EOS'):
31
+ pass
32
+ else:
33
+ data.append(make_row(node))
34
+ node = node.next
35
+
36
+ st.table(data)