import spacy # Load the English NER model. If needed: python -m spacy download en_core_web_sm nlp = spacy.load("en_core_web_sm") text = "Barack Obama was born in Honolulu and served as President of the United States." doc = nlp(text) for ent in doc.ents: print(ent.text, ent.label_)