From: Wilson Bilkovich Date: 2005-12-15T06:21:02+09:00 Subject: Re: English Ruby Home as a second class citizen On 12/14/05, Jacob Fugal wrote: > On 12/14/05, James Britt wrote: > > cap wrote: > > > I use > > > > > > http://www.google.com/language_tools?hl=en > > > > > > to guess what did they say > > > > Thanks. I can use that, or Alta Vista's Babel. > > > > What I could use is a tool that takes the Japanese RDF feed, runs it > > though a translator, and emits a new feed, to which I can subscribe. > > > > Hmm ... > > I've got a framework running at "http://jacob.fugal.net/era/" (ERA = > English Ruby Annoucements). The only portion lacking is the > translation. I couldn't find a web service that does japanese to > english and I didn't want to do screenscraping. If you can point me at > an appropriate webservice or write your own bit of screen scraping > code, I'll plug it in and you've got your feed! :) Does this lame little snippet help? Heh. Unfortunately, babelfish is limited to 150 words. Also, ruby-lang.org/ja uses EUC encoding, so if you're grabbing it directly, rather than in Unicode form, you'll want $KCODE="E" #jp.rb require 'open-uri' require 'cgi' $KCODE="u" exit unless ARGV[0] input = CGI.escape(ARGV[0]) trans = URI("http://babelfish.altavista.com/tr?doit=done&intl=1&tt=urltext&trtext=#{input}&lp=ja_en&btnTrTxt=Translate").read output = trans[/
(.*)<\/div>/, 1] puts output