【发布时间】:2017-10-29 10:39:12
【问题描述】:
我正在尝试在 nltk 中使用 ne_chunk 和 pos_tag 对句子进行分块。
from nltk import tag
from nltk.tag import pos_tag
from nltk.tree import Tree
from nltk.chunk import ne_chunk
sentence = "Michael and John is reading a booklet in a library of Jakarta"
tagged_sent = pos_tag(sentence.split())
print_chunk = [chunk for chunk in ne_chunk(tagged_sent) if isinstance(chunk, Tree)]
print print_chunk
结果如下:
[Tree('GPE', [('Michael', 'NNP')]), Tree('PERSON', [('John', 'NNP')]), Tree('GPE', [('Jakarta', 'NNP')])]
我的问题,是否可以不包括 pos_tag(如上面的 NNP)而只包括 Tree 'GPE'、'PERSON'? “GPE”是什么意思?
提前致谢
【问题讨论】:
标签: python tree tags nltk chunking