Skip to content

Instantly share code, notes, and snippets.

@sasanquaneuf
Last active January 15, 2016 12:53
Show Gist options
  • Save sasanquaneuf/86b0f4b39051792d6a11 to your computer and use it in GitHub Desktop.
Save sasanquaneuf/86b0f4b39051792d6a11 to your computer and use it in GitHub Desktop.
Windows10(64bit)のRubyでMeCabをつかう(Natto) ref: http://qiita.com/sasanquaneuf/items/e4e57b60d04b75d68f80
> gem install natto
> cd c:\temp\mecab
> ruby mecab.rb > temp.txt
> mecab input.txt -o out.txt
require 'natto'
text = '日本語を分解してしまいます。'
natto = Natto::MeCab.new
natto.parse(text) do |n|
puts "#{n.surface}: #{n.feature}"
end
日本語 名詞,一般,*,*,*,*,日本語,ニホンゴ,ニホンゴ
を 助詞,格助詞,一般,*,*,*,を,ヲ,ヲ
分解 名詞,サ変接続,*,*,*,*,分解,ブンカイ,ブンカイ
し 動詞,自立,*,*,サ変・スル,連用形,する,シ,シ
て 助詞,接続助詞,*,*,*,*,て,テ,テ
しまい 動詞,非自立,*,*,五段・ワ行促音便,連用形,しまう,シマイ,シマイ
ます 助動詞,*,*,*,特殊・マス,基本形,ます,マス,マス
。 記号,句点,*,*,*,*,。,。,。
EOS
日本語: 名詞,一般,*,*,*,*,日本語,ニホンゴ,ニホンゴ
を: 助詞,格助詞,一般,*,*,*,を,ヲ,ヲ
分解: 名詞,サ変接続,*,*,*,*,分解,ブンカイ,ブンカイ
し: 動詞,自立,*,*,サ変・スル,連用形,する,シ,シ
て: 助詞,接続助詞,*,*,*,*,て,テ,テ
しまい: 動詞,非自立,*,*,五段・ワ行促音便,連用形,しまう,シマイ,シマイ
ます: 助動詞,*,*,*,特殊・マス,基本形,ます,マス,マス
。: 記号,句点,*,*,*,*,。,。,。
: BOS/EOS,*,*,*,*,*,*,*,*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment