Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

A Ruby script adhering to the Ruby Way

Name: Anonymous 2006-10-17 11:11

Probably, I don't know what the Ruby Way is! (other than a book)  I did replace my tabs with two spaces, so and that should be enough!
#!/usr/bin/ruby -w
require 'net/http'

def babelfish text
  ['en|ja', 'ja|en'].inject(text) do |txt, pair|
    Net::HTTP.post_form(URI.parse('http://www.google.com/translate_t';), {:text => txt, :langpair => pair}).body.scan(/result_box dir=ltr>([^<]+)<\/div>/)[0][0].strip.gsub(/'/, "'")
  end
end

def nifty text
  ["EN,JA", "JA,EN"].inject(text) do |txt, pair|
    Net::HTTP.get_response(URI.parse("http://nifty.amikai.com/amitext/indexUTF8.jsp?translate=%E7%BF%BB%E8%A8%B3%E3%81%99%E3%82%8B&langpair=#;{URI.escape(pair)}&sourceText=#{URI.escape(txt)}")).body.scan(/translatedText" rows="5">([^<]+)<\/textarea>/)[0][0].strip.gsub(/'/, "'")
  end
end

exit 1 if ARGV.empty?
str = ARGV.join ' '
begin
  while true
    [:babelfish, :nifty].each do |meth|
      str = self.method(meth).call str
      puts str
    end
  end
rescue Interrupt
  # ...
end
Use like this:
./babel.rb hello im fairX the haxxor join my community of hackers if you payme enough i will give you access to a private area of haxx \;\)Output:
  Today as for im fairX access to the private use area of payme me haxx of haxxor sufficient; If it gives, it joins to my community of the hacker)
  im fairX access to the private use area of payme -- being related -- haxx; of today, me, and sufficient haxxor -- it connects with a hacker's community of me, when it gives.
  The access of im fairX to the private use use area of payme -- It is related, but it is -- haxx; Today, me, and sufficient haxxor -- When my community of the hacker giving, you connect that.
  payme (it is associated.) However, it is access of im fairX to the private use use area of that's right.   haxx; today, me, and sufficient haxxor -- My community of giving a hacker when and it are connected.
[...]

Name: Anonymous 2006-10-17 13:00 (sage)

goggles, do nothing, etc.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List