我一直在尝试Python NLTK Book中的一些示例。例如,第 7 章用这个例子讨论了 Chinking:
grammar = r"""
NP:
{<.*>+} # Chunk everything
}<VBD|IN>+{ # Chink sequences of VBD and IN
"""
sentence = [("the", "DT"), ("little", "JJ"), ("yellow", "JJ"),
("dog", "NN"), ("barked", "VBD"), ("at", "IN"), ("the", "DT"), ("cat", "NN")]
cp = nltk.RegexpParser(grammar)
result = cp.parse(sentence)
据我说,这应该从结果中剔除“吠叫”。但事实并非如此。我是 python 和 nltk 的新手,但是我在这里缺少什么?这里有什么明显需要更新的地方吗?谢谢..