mosesdecoder/server/sgclient.perl
bhaddow 904133fcb7 Merge in the multiple models branch. These changes allow the moses server
to support multiple translation, language and generation models within the
same process. The main design change is the introduction of a TranslationSystem
object to manage the models, which have been moved out of StaticData.
The changes should have no effect on existing systems.


git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@3394 1f5c12ca-751b-0410-a591-d2e778427230
2010-08-10 13:12:00 +00:00

53 lines
1.3 KiB
Perl
Executable File

#!/usr/bin/env perl
#
# Sample client to print out the search graph
#
use Encode;
use XMLRPC::Lite;
use utf8;
$url = "http://localhost:8086/RPC2";
$proxy = XMLRPC::Lite->proxy($url);
$text = "il a souhaité que la présidence trace à nice le chemin pour l' avenir .";
#$text = "je ne sais pas";
# Work-around for XMLRPC::Lite bug
$encoded = SOAP::Data->type(string => Encode::encode("utf8",$text));
#my %param = ("text" => $encoded );
my %param = ("text" => $encoded , "sg" => "true", "topt" => "true");
#my %param = ("text" => $encoded , "topt" => "true");
die "translation failed" unless $result = $proxy->call("translate",\%param)->result;
print $result->{'text'} . "\n";
exit;
if ($result->{'sg'}) {
print "Search graph: \n";
$sg = $result->{'sg'};
foreach my $sgn (@$sg) {
foreach my $key (keys %$sgn) {
my $value = $sgn->{$key};
print "$key=$value ";
}
print "\n";
}
}
if ($result->{'topt'}) {
print "Translation options: \n";
$sg = $result->{'topt'};
foreach my $sgn (@$sg) {
foreach my $key (keys %$sgn) {
my $value = $sgn->{$key};
if (ref($value) eq 'ARRAY') {
$value = join(",", @$value);
}
print "$key=$value ";
}
print "\n";
}
}