Rubyでつくる Twitter bot(MeCabで形態素解析編)
形態素解析もかんたん!
require "MeCab" word = "こんにちは。今日はいい天気ですね!" mecab = MeCab::Tagger.new() node = mecab.parseToNode(word) while node # 名詞だったら出力する f = node.feature.split(',')[0] puts (f1 == "名詞" ? node.surface : nil) node = node.next end