我不熟悉NLTK
这是我用过的密码
text="The pizza was 66 and brilliant"
pattern = r"""
P: {<NN>+<VBD>+<CD>+}
"""
for sent in sent_tokenize(text):
sentence = sent.split()
PChunker = RegexpParser(pattern)
output= PChunker.parse(pos_tag(sentence))
print(output)
我得到输出
^{pr2}$我需要输出
pizza was 66
我怎么才能得到这个?在
的输出RegexpParser.parse是一个可以循环使用的树树.子树. 尝试以下操作,立即筛选出您感兴趣的非终端节点(在您的示例中是P):
相关问题 更多 >
编程相关推荐