Created
December 30, 2012 06:27
-
-
Save komasaru/4411250 to your computer and use it in GitHub Desktop.
Ruby script to test of mecab.
This file contains 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
# -*- encoding: utf-8 -*- | |
require 'MeCab' | |
sentence = "太郎はこの本を二郎を見た女性に渡した。" | |
begin | |
c = MeCab::Tagger.new | |
n = c.parseToNode(sentence) | |
while n do | |
print n.surface, "\t", n.feature, "\t", n.cost, "\n" | |
n = n.next | |
end | |
print "EOS\n"; | |
rescue | |
print "RuntimeError: ", $!, "\n"; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment