Marcação de classe gramatical

Feature Engineering para NLP em Python

Rounak Banik

Data Scientist

Aplicações

  • Desambiguação de sentido de palavras
    • "The bear is a majestic animal"
    • "Please bear with me"
  • Análise de sentimento
  • Resposta a perguntas
  • Detecção de fake news e spam de opinião
Feature Engineering para NLP em Python

Marcação de POS

  • Atribuir a cada palavra sua classe gramatical correspondente.
    "Jane is an amazing guitarist."
    
  • Marcação de POS:
    • Jane → substantivo próprio
    • is → verbo
    • an → determinante
    • amazing → adjetivo
    • guitarist → substantivo
Feature Engineering para NLP em Python

Marcação de POS com 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 para NLP em Python

Marcação de POS com 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 para NLP em Python

Anotações de POS no spaCy

Documentação do spaCy sobre anotações de POS

Feature Engineering para NLP em Python

Vamos praticar!

Feature Engineering para NLP em Python

Preparing Video For Download...