I am trying to execute a python script to tag POS through PHP. But it does not return a full exit.
Python script:
import nltk
import sys
text = sys.argv[1]
tokenize_into_words = nltk.word_tokenize(text)
print text
result = nltk.pos_tag(tokenize_into_words)
print result
print "Done!"
Php script
$cmd = 'python /Library/WebServer/Documents/varticle/vcmdpos.py ' . $string2;
$tmp = exec($cmd,$output);
print_r($output);
Team:
python / Library / WebServer / Documents / varticle / vcmdpos.py Scientists
Observed output:
Array ([0] => Scientists)
Expected Conclusion:
Array ([0] => Scientists [1] => "[(" Scientists "," NNS ")]" [2] => "Done!")
When I run the command manually, it starts for about 5-10 seconds to run. [This may be due to the time required to mark the POS or import nltk.]
But when launched through PHP, it immediately returns and outputs an expression from nltk.pos_tag or print after it does not return.
Did I miss something?
source
share