Skip to content

Instantly share code, notes, and snippets.

@sasamijp
Created August 16, 2015 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sasamijp/7c0996f33393f234bd2e to your computer and use it in GitHub Desktop.
Save sasamijp/7c0996f33393f234bd2e to your computer and use it in GitHub Desktop.
日本語をわいらの言葉に変換するやで
# -*- 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