mosesdecoder/server/client.perl
bhaddow 4874f711ca Update mosesserver so that it can return the search graph and/or
translation options. Also add a sample client to demonstrate
these new features.


git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@3265 1f5c12ca-751b-0410-a591-d2e778427230
2010-05-20 16:52:46 +00:00

30 lines
787 B
Perl
Executable File

#!/usr/bin/env perl
#
# Sample client for mosesserver, illustrating allignment info
#
use Encode;
use XMLRPC::Lite;
use utf8;
$url = "http://localhost:8080/RPC2";
$proxy = XMLRPC::Lite->proxy($url);
$text = "il a souhaité que la présidence trace à nice le chemin pour l' avenir .";
# Work-around for XMLRPC::Lite bug
$encoded = SOAP::Data->type(string => Encode::encode("utf8",$text));
my %param = ("text" => $encoded, "align" => "true");
$result = $proxy->call("translate",\%param)->result;
print $result->{'text'} . "\n";
if ($result->{'align'}) {
print "Phrase alignments: \n";
$aligns = $result->{'align'};
foreach my $align (@$aligns) {
print $align->{'tgt-start'} . "," . $align->{'src-start'} . ","
. $align->{'src-end'} . "\n";
}
}