import spacy
nlp = spacy.load("en_core_web_sm")
doc = nlp("NASA awarded Elon Musk’s SpaceX a $2.9 billion contract to build the lunar lander.")
for ent in doc.ents:
print(ent.text, ent.label_)
# Construction via add_pipe with default model
ner = nlp.add_pipe("ner")
# Construction via add_pipe with custom model
config = {"model": {"@architectures": "my_ner"}}
parser = nlp.add_pipe("ner", config=config)
# Construction from class
from spacy.pipeline import EntityRecognizer
ner = EntityRecognizer(nlp.vocab, model)