Feature Engineering for NLP in Python
Rounak Banik
Data Scientist
"The bear is a majestic animal"
"Please bear with me"
"Jane is an amazing guitarist."
Jane
→ proper nounis
→ verban
→ determineramazing
→ adjectiveguitarist
→ nounimport spacy
# Load the en_core_web_sm model
nlp = spacy.load('en_core_web_sm')
# Initiliaze string
string = "Jane is an amazing guitarist"
# Create a Doc object
doc = nlp(string)
...
...
# Generate list of tokens and pos tags
pos = [(token.text, token.pos_) for token in doc]
print(pos)
[('Jane', 'PROPN'),
('is', 'VERB'),
('an', 'DET'),
('amazing', 'ADJ'),
('guitarist', 'NOUN')]
PROPN
→ proper nounDET
→ determinantFeature Engineering for NLP in Python