NLP Task Snippets
Named Entity Recognition (NER) with spaCy
import spacy

# Load the English language model
# Model details: https://spacy.io/models/en#en_core_web_sm
nlp = spacy.load('en_core_web_sm')

# Sample text
text = 'Jon is flying to Amsterdam on Delta Airlines next week.'

# Process the text
doc = nlp(text)

# Print Named Entity Recognition (NER) tags
for ent in doc.ents:
    print(f'{ent.text} [{ent.label_}]')
        

OUTPUT


Amsterdam [GPE]
Delta Airlines [ORG]
next week [DATE]