0

The perl command is

perl /opt/translation/moses/scripts/tokenizer/tokenizer.perl -l en < Eng-hin.translation.en > Input/tokenization/Eng-hin.translation.tok.en

I want to execute the above perl command in python script ,Here the perl command is executed successfully in Popen() but no output file is created at location "Input/tokenization/Eng-hin.translation.tok.en".

var = "-l en  <   Input/Corpus/"+inputfilename+" > Input/tokenization/Eng-hin.translation.tok.en"
pipe = subprocess.Popen(["perl",
                         "/opt/translation/moses/scripts/tokenizer/tokenizer.perl",
                         var
                         ])

Can someone tell me whats happening behind ?

2
Contributors
1
Reply
9
Views
2 Years
Discussion Span
Last Post by woooee
1

First, try it with "shell=True" (see the link below). And post which version of Python and the OS you are using.

You can capture the output and write it to a file yourself so you know if you are getting that far or not. See the Python Module of the Week's "capturing output" http://pymotw.com/2/subprocess/index.html#capturing-output (and subprocess.call should work just fine for calling/running the program).

The code you posted has one error that I can see, although we can not run it because we don't have the perl script. There a missing slash for the directory at the beginning of the output file i.e. should be "> /Input/tokenization/Eng-hin.translation.tok.en"

Edited by woooee

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.