我正在尝试将 SENNA 与 python 一起使用。我得到以下信息IOError
:
Traceback (most recent call last):
File "C:\Python27\senna_test.py", line 18, in <module>
tagged = StringIO(p.communicate(sentence)[0])
File "C:\Python27\lib\subprocess.py", line 479, in communicate
return self._communicate(input)
File "C:\Python27\lib\subprocess.py", line 718, in _communicate
self.stdin.write(input)
IOError: [Errno 22] Invalid argument
我的代码如下:
import os
import csv
from StringIO import StringIO
import subprocess as sp
from nltk.draw.tree import Tree, TreeWidget
from nltk.draw.util import CanvasFrame
senna_path="C:/Python27/senna/"
sentence = 'My brother has a dog'
# read senna output
p = sp.Popen(['blabla', '-path', senna_path],
executable=os.path.join(senna_path, 'senna-win32.exe'),
stdin=sp.PIPE,
stdout=sp.PIPE,
stderr=sp.PIPE)
tagged = StringIO(p.communicate(sentence)[0])
table = csv.reader(tagged, dialect='excel-tab')