从 spacy 中的名词块中删除名称

Removing names from noun chunks in spacy

有没有办法删除名词块中的人名?

这是代码

import en_vectors_web_lg
nlp = en_vectors_web_lg.load()
text = "John Smith is lookin for Apple ipod"
doc = nlp(text)
for chunk in doc.noun_chunks:
     print(chunk.text)

当前输出

John Smith
Apple ipod

我想要像下面这样的输出,其中忽略了人名。如何实现?

Apple ipod

引用spaCy ents

import spacy
# loading the model
nlp = spacy.load('en_core_web_lg')
doc = nlp(u'"John Smith is lookin for Apple ipod"')
# creating the filter list for tokens that are identified as person
fil = [i for i in doc.ents if i.label_.lower() in ["person"]]
# looping through noun chunks
for chunk in doc.noun_chunks:
    # filtering the name of the person
    if chunk not in fil:
        print(chunk.text)

输出:

Apple ipod

希望对您有所帮助。