这是一个可以使用 Python 实现的实体链接模型的例子:
import spacyfrom spacy.tokens import Span
nlp = spacy.load("en_core_web_sm")
def entity_linker(doc):
# Iterate over the entities
for ent in doc.ents:
# Check if the entity is a person
if ent.label_ == "PERSON":
# Find the Wikipedia page for the person
page = wikipedia.page(ent.text)
# Create a new Span for the entity with the Wikipe