1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

■【Google Colaboratory】形態素解析(janome)を使う

Last updated at Posted at 2020-05-20

日本語の形態素解析ツール janome の使い方を紹介。
JanomeはPythonの形態素解析エンジン。
日本語のテキストを形態素ごとに分割して品詞を判定したり分かち書き(単語に分割)することができる

1. Install of "janome"


!pip install janome

2. How to use


from janome.tokenizer import Tokenizer
s = Tokenizer() # <- トークナイザのインスタンスを生成
t = 'にわにわにわにわとりがいる'
tt = '庭には二羽ニワトリがいる'
for _ in s.tokenize(t):
  print(_)
for __ in s.tokenize(tt):
  print(__)

[Output] ===================================================
に ----- 助詞,格助詞,一般,,,,に,ニ,ニ
わに ----- 名詞,一般,
,,,,わに,ワニ,ワニ
わに ----- 名詞,一般,
,,,,わに,ワニ,ワニ
わ ----- 助詞,終助詞,
,,,,わ,ワ,ワ
にわとり ----- 名詞,一般,
,,,,にわとり,ニワトリ,ニワトリ
が ----- 助詞,格助詞,一般,
,,,が,ガ,ガ
いる ----- 動詞,自立,,,一段,基本形,いる,イル,イル

庭 ----- 名詞,一般,,,,,庭,ニワ,ニワ
に ----- 助詞,格助詞,一般,,,,に,ニ,ニ
は ----- 助詞,係助詞,
,,,,は,ハ,ワ
二 ----- 名詞,数,
,,,,二,ニ,ニ
羽 ----- 名詞,接尾,助数詞,
,,,羽,ワ,ワ
ニワトリ ----- 名詞,一般,,,,,ニワトリ,ニワトリ,ニワトリ
が ----- 助詞,格助詞,一般,,,,が,ガ,ガ
いる ----- 動詞,自立,
,*,一段,基本形,いる,イル,イル
[end] ======================================================

Reference

形態素解析ツールの比較 (NLP2018)

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?