Skip to content

Instantly share code, notes, and snippets.

@komasaru
Created December 30, 2012 06:27
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 komasaru/4411250 to your computer and use it in GitHub Desktop.
Save komasaru/4411250 to your computer and use it in GitHub Desktop.
Ruby script to test of mecab.
# -*- 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