R-1グランプリおもしろかった。
かなりレベルが高かったように思います。
僕の中ではCOWCOW山田與志さんが優勝でした。
http://www.youtube.com/watch?v=nO_ycifUJG8でR-1サバイバルステージより夙川アトムさんが健闘してたと思うんですが、
ギョーカイ用語変換機をつくってみた。
http://sportare.jp/gyokai_yogo/※かなりむりやりな変換してます。
c = MeCab::Tagger.new("")
@sentence.gsub!(/\s| /, "")
n = c.parseToNode(@sentence)
@converted_sentence = ""
while n do
unless n.surface.blank?
feature = n.feature.split(/\,/)
word = feature.pop
chars = word.split(//)
word_size = chars.size
converted_word = ""
noun_one_changed ||= false
noun_one_changed = noun_one_changed
if feature[0] == "名詞"
if feature[1] == "数"
elsif feature[1] == "接尾"
else
if word_size == 1
vowel = vowel(chars[0])
unless vowel == "?"
converted_word = vowel + "ー" + chars[0]
noun_one_changed = true
end
elsif word_size == 2
converted_word = chars[1] + "ー" + chars[0]
elsif word_size == 3
if chars[1] == "ン"
converted_word = chars[2] + chars[0] + chars[1]
else
converted_word = chars[1] + chars[2] + chars[0]
end
elsif word_size == 4
converted_word = chars[2] + chars[3] + chars[0] + chars[1]
elsif word_size == 5 && chars[4] == "ン"
converted_word = chars[2] + chars[3] + chars[0] + chars[1]
end
end
elsif feature[0] == "形容詞"
if feature[1] == "自立" && word_size == 3
converted_word = chars[1] + chars[2] + chars[0] + "ー"
end
elsif feature[0] == "助詞"
if noun_one_changed
n = n.next
next
end
end
unless converted_word.blank?
@converted_sentence += converted_word
else
@converted_sentence += n.surface
end
end
n = n.next
end
@converted_sentence.gsub!(/おねえちゃん/, "チャンネー")
@converted_sentence.gsub!(/六本木/, "ギロッポン")
@converted_sentence = @converted_sentence + " ハイきたドーン!"
「おねえちゃん」と「六本木」だけはルール外だけど変換したかったから最後に変換してみた。
<変換例>
「ラーメンがうまい。」→「メンラーがマイウー。」
「ドラえもん」→「エモドラ」
作成には以下のサイトを参考にさせていただきました。
http://mecab.sourceforge.net/
http://i-am.web777.net/2007/02/mecabruby.html
http://d.hatena.ne.jp/aike/20080105
http://www.kobayashiakira.com/blog/index.php?c=8-&page=1
すべてのコトバを変換できるようにするには、なかなかしんどそうなのでこの辺で。