ontonotes.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:allennlp 作者: allenai 项目源码 文件源码
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 = []
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号