import re
import subprocess
sub = subprocess.Popen(['/home/karthik/Downloads/stanford-parser-2011-06- 08/lexparser.csh'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr = subprocess.PIPE)
sub.stdin.write("i am a fan of ac milan which is the best club in the world")
relns = []
while(True):
rel = sub.stdout.readline()
m = re.search("Sentence skipped", rel)
if m != None:
print 'stop'
sys.exit(0)
if rel == '\n':
break
relns.append(rel)
print relns
sub.terminate()
だから私は、スタンフォード パーサーと lexparser.csh を使用して、このテキスト行を解析したいと考えています。しかし、このコードを実行すると、デフォルトのテキストの出力が得られます。で指定された実際のテキストは解析されていません。それで、私はパイプを正しい方法で使用していますか?そして、多くの例で見てきました - コマンドと一緒に「-」が使用されています。なぜそれが使用されているのですか?私がそれを使用すると、スクリプトは sub.stdout.readline() で停止するだけです