Created
August 16, 2015 13:04
-
-
Save sasamijp/7c0996f33393f234bd2e to your computer and use it in GitHub Desktop.
日本語をわいらの言葉に変換するやで
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 'natto' | |
@natto = Natto::MeCab.new | |
def conv(jp_text) | |
words = [] | |
@natto.parse(jp_text) do |n| | |
break if n.is_eos? | |
case n.feature.split(',')[0] | |
when '名詞' | |
words << 'わい' | |
else words << n.surface | |
end | |
end | |
words.join('') | |
end | |
puts conv gets.chomp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment