Created
April 28, 2011 08:04
-
-
Save akiym/945998 to your computer and use it in GitHub Desktop.
Google CGI API for Japanese Input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Encode; | |
use JSON; | |
use LWP::UserAgent; | |
use URI; | |
use Data::Dumper; | |
use Data::Recursive::Encode; | |
my $text = shift or die; | |
my $uri = URI->new('http://www.google.com/transliterate'); | |
$uri->query_form(langpair => 'ja-Hira|ja', text => $text); | |
my $ua = LWP::UserAgent->new(); | |
my $res = $ua->get($uri); | |
my $json = $res->content; | |
my $content = JSON->new->relaxed(1)->decode($json); | |
warn Dumper(Data::Recursive::Encode->encode_utf8($content)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment