Skip to content

Instantly share code, notes, and snippets.

@buruzaemon
Created October 28, 2011 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buruzaemon/1322209 to your computer and use it in GitHub Desktop.
Save buruzaemon/1322209 to your computer and use it in GitHub Desktop.
Natto Snippets
require 'natto'
nm = Natto::MeCab.new
=> #<Natto::MeCab:0x288f6d08 @ptr=#<FFI::Pointer address=0x28d3ab80>,
@options={},
@dicts=[#<Natto::DictionaryInfo:0x288f6ba0 filename="/usr/local/lib/mecab/dic/ipadic/sys.dic", charset="utf-8">],
@version="0.98">
puts nm.version
=> 0.98
puts nm.dicts.first.filename
=> /usr/local/lib/mecab/dic/ipadic/sys.dic
puts nm.dicts.first.charset
=> utf-8
nm.parse('暑い日にはもってこいの一品ですね。') do |n|
puts "#{n.surface}\t#{n.feature}"
end
暑い 形容詞,自立,*,*,形容詞・アウオ段,基本形,暑い,アツイ,アツイ
日 名詞,非自立,副詞可能,*,*,*,日,ヒ,ヒ
に 助詞,格助詞,一般,*,*,*,に,ニ,ニ
は 助詞,係助詞,*,*,*,*,は,ハ,ワ
もってこい 名詞,一般,*,*,*,*,もってこい,モッテコイ,モッテコイ
の 助詞,連体化,*,*,*,*,の,ノ,ノ
一品 名詞,一般,*,*,*,*,一品,イッピン,イッピン
です 助動詞,*,*,*,特殊・デス,基本形,です,デス,デス
ね 助詞,終助詞,*,*,*,*,ね,ネ,ネ
。 記号,句点,*,*,*,*,。,。,。
BOS/EOS,*,*,*,*,*,*,*,*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment