Created
October 28, 2011 13:00
-
-
Save buruzaemon/1322209 to your computer and use it in GitHub Desktop.
Natto Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts nm.version | |
=> 0.98 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts nm.dicts.first.filename | |
=> /usr/local/lib/mecab/dic/ipadic/sys.dic | |
puts nm.dicts.first.charset | |
=> utf-8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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