#!/usr/local/bin/perl

use IPC::Open2;

#$command = "/shared/code/Lexicon/src/GetProbs";
$command = "/barrow/usr1/shared/code/Lexicon/src/TestLexicon";
$probfile = "/barrow/usr1/shared/data/Chinese/GIZA.fge";
#$probfile = "/shared/data/Chinese/GIZA.egf";
$pid = open2($lexread, $lexwrite, $command, $probfile);

binmode($lexwrite, ":encoding(gbk)");

$line = <$lexread>; print $line;
$line = <$lexread>; print $line;
$line = <$lexread>; print $line;
$line = <$lexread>; print $line;
$line = <$lexread>; print $line;

#binmode(STDOUT, ":utf8");

sub getLexProbs {
    my($src, $tgt) = @_;
    my($logprob, $avgprob);
    print $lexwrite "$src\n"; # Chinese
    print $lexwrite "$tgt\n"; # English
    $logprob = <$lexread>;
    chomp($logprob);
    #print STDERR "tprob $tprob\n";
    $avgprob = <$lexread>;
    chomp($avgprob);
    return $logprob;
}

