Feature Engineering for NLP in Python
Rounak Banik
Data Scientist
"John Doe is a software engineer working at Google. He lives in France."
John Doe
→ personGoogle
→ organizationFrance
→ country (geopolitical entity)import spacy string = "John Doe is a software engineer working at Google. He lives in France." # Load model and create Doc object nlp = spacy.load('en_core_web_sm') doc = nlp(string)
# Generate named entities ne = [(ent.text, ent.label_) for ent in doc.ents] print(ne)
[('John Doe', 'PERSON'), ('Google', 'ORG'), ('France', 'GPE')]
Feature Engineering for NLP in Python