from nltk.corpus.reader.conll import ConllCorpusReader
READER = ConllCorpusReader(root="./", fileids=".conll",
columntypes=('words','pos','tree','chunk','ne','srl','ignore')
)
READER_sents(myConLLfile)
我正在从一个.conll
文件中将句子提取为字符串列表。上面的代码没有报告任何错误,因此我认为每个句子都提取了一些内容。然而,当我试图打印出每个句子或在每个句子中添加词性标签时,下面的值错误会出现在第1007个句子之后的每个句子中
i = 0
for sentence in READER_sents(myConLLfile):
print(i)
print(sentence)
i += 1
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-125-9c03d8d69ec0> in <module>()
1 i = 0
----> 2 for sentence in READER.sents(myConLLfile):
3 print(i)
4 print(sentence)
5 i += 1
2 frames
/usr/local/lib/python3.6/dist-packages/nltk/corpus/reader/conll.py in _read_grid_block(self, stream)
206 if len(row) != len(grid[0]):
207 raise ValueError('Inconsistent number of columns:\n%s'
--> 208 % block)
209 grids.append(grid)
210 return grids
ValueError: Inconsistent number of columns:
This O
guy O
needs O
his O
own O
show O
on O
Discivery B-corporation
Channel I-corporation
! O
目前没有回答
相关问题 更多 >
编程相关推荐