,可以通过以下步骤实现:
import spacy
# 加载英文模型
nlp = spacy.load("en_core_web_sm")
text = "Apple is looking at buying U.K. startup for $1 billion"
doc = nlp(text)
entities = []
for entity in doc.ents:
entities.append(entity)
for entity in entities:
entity.start_char = 0
entity.end_char = 0
non_entities = [token.text for token in doc if not token.ent_type_]
result = " ".join(non_entities)
完成以上步骤后,变量result
将包含从spacy对象中删除命名实体后的文本内容。
关于spacy的更多信息和使用方法,可以参考腾讯云的自然语言处理(NLP)相关产品:腾讯云自然语言处理(NLP)。
领取专属 10元无门槛券
手把手带您无忧上云