Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
require 'mecab'
sentence = "ゲームしてからスケベしよう"
mecab =
node = mecab.parseToNode(sentence)
word_array = []
node =
if /^名詞/ =~ node.feature.force_encoding("UTF-8")
word_array << node.surface.force_encoding("UTF-8")
end until"BOS/EOS")
p word_array
#["ゲーム", "スケベ"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment