Part-of-speech tagging

Feature Engineering per NLP in Python

Rounak Banik

Data Scientist

Applicazioni

  • Disambiguazione del senso delle parole
    • "The bear is a majestic animal"
    • "Please bear with me"
  • Analisi del sentiment
  • Question answering
  • Rilevamento di fake news e spam di opinione
Feature Engineering per NLP in Python

POS tagging

  • Assegnare a ogni parola la sua parte del discorso.
    "Jane is an amazing guitarist."
    
  • POS Tagging:
    • Jane → nome proprio
    • is → verbo
    • an → determinante
    • amazing → aggettivo
    • guitarist → sostantivo
Feature Engineering per NLP in Python

POS tagging con 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 per NLP in Python

POS tagging con 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 per NLP in Python

Annotazioni POS in spaCy

Documentazione spaCy sulle annotazioni POS

Feature Engineering per NLP in Python

Esercitiamoci!

Feature Engineering per NLP in Python

Preparing Video For Download...