chunkers.py 文件源码

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

项目:Natural-Language-Processing-Python-and-NLTK 作者: PacktPublishing 项目源码 文件源码
def conll_tag_chunks(chunk_sents):
    '''Convert each chunked sentence to list of (tag, chunk_tag) tuples,
    so the final result is a list of lists of (tag, chunk_tag) tuples.
    >>> from nltk.tree import Tree
    >>> t = Tree('S', [Tree('NP', [('the', 'DT'), ('book', 'NN')])])
    >>> conll_tag_chunks([t])
    [[('DT', 'B-NP'), ('NN', 'I-NP')]]
    '''
    tagged_sents = [tree2conlltags(tree) for tree in chunk_sents]
    return [[(t, c) for (w, t, c) in sent] for sent in tagged_sents]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号