Skip to content

Instantly share code, notes, and snippets.

@kamatari
Last active July 10, 2016 01:12
Show Gist options
  • Save kamatari/7b31e13e6d7b1280776df5030f9de277 to your computer and use it in GitHub Desktop.
Save kamatari/7b31e13e6d7b1280776df5030f9de277 to your computer and use it in GitHub Desktop.
require 'natto'
text = 'すもももももももものうち'
natto = Natto::MeCab.new
natto.parse(text) do |n|
if n.feature.split(',')[0] == '名詞'
puts "#{n.surface}\t#{n.feature}"
end
end
====
すもも 名詞,一般,*,*,*,*,すもも,スモモ,スモモ
もも 名詞,一般,*,*,*,*,もも,モモ,モモ
もも 名詞,一般,*,*,*,*,もも,モモ,モモ
うち 名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment