Create a gist now

Instantly share code, notes, and snippets.

日本語をわいらの言葉に変換するやで
# -*- 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