# Janomeによる形態素解析と形態素を見やすく整形 mecabめんどうだったのでInstall ```bash # https://github.com/mocobeta/janome pip install janome ``` ## example_janome.py ```py3 # 見づらい from janome.tokenizer import Tokenizer t = Tokenizer() for token in t.tokenize(u'すもももももももものうち'): print(token) print(type(token)) for attr_name in dir(token): if attr_name.startswith("_"): continue attr = getattr(token, attr_name) print(attr_name, attr, type(attr)) break ``` ``` すもも 名詞,一般,*,*,*,*,すもも,スモモ,スモモ base_form すもも infl_form * infl_type * node_type SYS_DICT part_of_speech 名詞,一般,*,* phonetic スモモ reading スモモ surface すもも ``` janome_token_dataframe.py ```py3 import pandas as pd from janome.tokenizer import Tokenizer pd.DataFrame( {attr_name: getattr(token, attr_name) for attr_name in dir(token) if not attr_name.startswith("_")} for token in Tokenizer().tokenize(u'すもももももももものうち') ) ```
base_form infl_form infl_type node_type part_of_speech phonetic reading surface
0 すもも * * SYS_DICT 名詞,一般,*,* スモモ スモモ すもも
1 * * SYS_DICT 助詞,係助詞,*,*
2 もも * * SYS_DICT 名詞,一般,*,* モモ モモ もも
3 * * SYS_DICT 助詞,係助詞,*,*
4 もも * * SYS_DICT 名詞,一般,*,* モモ モモ もも
5 * * SYS_DICT 助詞,連体化,*,*
6 うち * * SYS_DICT 名詞,非自立,副詞可能,* ウチ ウチ うち