If you want to interact with Moses from the keyboard as you're trying to do
below, just run:
> moses -config moses.ini 2>/dev/null | awk 'BEGIN {print "Enter some
text:"} {print "Response: "$0"\n"}'
If you need something more involved, you can use the perl open3 library in
your program to interact with the stdin/stdout/stderr of the child process.
Adam
On Mon, Feb 9, 2009 at 1:22 PM, Vineet Kashyap <[email protected]>wrote:
> Hi
>
> I am trying to write a perl script that can send input from KEYBOARD
> and get the output back to the program which should have the
> translation stored in a variable.
>
> So far, i have this:
>
> print TERMINAL "Enter some text: ";
>
> while (<KEYBOARD>) {
>
> last if /quit/; # stop when 'quit' is entered
> print; # send keyboard input to the program
> while($reply = <STDIN>) { # get (first line of) reply from program
>
> chop $reply; # remove trailing "\n" character
> open FILE, ">file.txt" or die $!;
> print FILE $reply;
> close FILE;
> print TERMINAL "Response: \"$reply\"\n\n";
> }
>
> }
>
> print TERMINAL "\nDone.\n";
>
> kill $pid;
> exit;
>
> This is just part of the program. All this does is starts Moses as
> a child process using the exec command with arguments.
> gets input from the KEYBOARD but the problem is the output it prints
> everything that moses prints out; so i tried using a FILE but that gets
> only the last thing which is "Finished translating"
>
> Is there a way to get the translation and store it in a variable ?
>
> Thanks,
>
> Vineet
>
>
> _______________________________________________
> Moses-support mailing list
> [email protected]
> http://mailman.mit.edu/mailman/listinfo/moses-support
>
_______________________________________________
Moses-support mailing list
[email protected]
http://mailman.mit.edu/mailman/listinfo/moses-support