【发布时间】:2021-02-23 00:29:44
【问题描述】:
如何使用 spaCy 从句子中删除实体? 我想随机删除 ORP、GPE、Money、Ordinal 或 Percent 实体。 例如,
唐纳德·约翰·特朗普[人](生于 1946 年 6 月 14 日)[日期] 是美国第 45 任[序数] 和现任总统 [GPE]。在进入政界之前,他是一名商人和电视名人。
现在如何从这句话中删除某个实体? 在此示例中,该函数选择删除第 45 个序数实体。
>>> sentence = 'Donald John Trump (born June 14, 1946) is the 45th and current president of the United States. Before entering politics, he was a businessman and television personality.'
>>> remove(sentence)
45th
【问题讨论】: