Skip to content

Instantly share code, notes, and snippets.

@morygonzalez
Created June 7, 2012 16:51
Show Gist options
  • Save morygonzalez/2890014 to your computer and use it in GitHub Desktop.
Save morygonzalez/2890014 to your computer and use it in GitHub Desktop.
erokimos.rb based on https://gist.github.com/1131746
# -*- coding: utf-8 -*-
# depends on Yahoo! Japan Web API
# http://help.yahoo.co.jp/help/jp/developer/developer-06.html
#
# usage:
# e.g. :erokimos 眠い # => update 'たわわに眠い' [Yn]
#
require 'net/http'
require 'nokogiri'
Earthquake.init do
command :erokimos do |m|
noun_prefix = %w[こんもりした 恥じらうような たわわに実る 熟れた 爛れた 濡れた 黒光りする びっしりと密生した もりあがった 甘美な びしょ濡れの ぐしょ濡れの むっちりとした むっちりした 柔らかな 突起した 盛り上がった 嗚咽にも似た ピンク色の 薄紫色の 一糸纏わぬ 光沢のある 熱のこもった ヌメヌメとした ヌルヌルとした]
verb_prefix = %w[こんもりと 恥じらいながら 恥じらうように たわわに実らせて ぐっしょりと びっしょりと たわわに 微かに 大胆にも もじもじと]
# enter your app_id here
app_id = ''
buf = ''
response = nil
Net::HTTP.start('jlp.yahooapis.jp', 80) {|http|
response = http.post('/MAService/V1/parse', "appid=#{app_id}&sentence=#{m[1]}")
}
doc = Nokogiri::XML(response.body)
doc.css('word_list word').each do |w|
prefix = nil
if w.css('pos').text =~ /^(動詞|形容詞)/
prefix = verb_prefix
elsif w.css('pos').text =~ /^名詞/
prefix = noun_prefix
end
buf += prefix[rand(prefix.size)] if prefix
buf += w.css('surface').text
end
input buf
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment