Part-of-speech tagging

Feature Engineering for NLP in Python

Rounak Banik

Data Scientist

Applications

  • Word-sense disambiguation
    • "The bear is a majestic animal"
    • "Please bear with me"
  • Sentiment analysis
  • Question answering
  • Fake news and opinion spam detection
Feature Engineering for NLP in Python

POS tagging

  • Assigning every word, its corresponding part of speech.
    "Jane is an amazing guitarist."
    
  • POS Tagging:
    • Janeproper noun
    • isverb
    • andeterminer
    • amazingadjective
    • guitaristnoun
Feature Engineering for NLP in Python

POS tagging using spaCy

import 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)
Feature Engineering for NLP in Python

POS tagging using spaCy

...
...
# 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')]
Feature Engineering for NLP in Python

POS annotations in spaCy

spaCy documentation on POS annotations

Feature Engineering for NLP in Python

Let's practice!

Feature Engineering for NLP in Python

Preparing Video For Download...