def sentence_iterator(self, file_path: str) -> Iterator[OntonotesSentence]:
"""
An iterator over the sentences in an individual CONLL formatted file.
"""
with codecs.open(file_path, 'r', encoding='utf8') as open_file:
conll_rows = []
for line in open_file:
line = line.strip()
if line != '' and not line.startswith('#'):
conll_rows.append(line)
else:
if not conll_rows:
continue
else:
yield self._conll_rows_to_sentence(conll_rows)
conll_rows = []
评论列表
文章目录