Análise de sentimento em texto de fala

Processamento de Linguagem Falada em Python

Daniel Bourke

Machine Learning Engineer/YouTube Creator

Instalando bibliotecas de análise de sentimento

$ pip install nltk
# Baixar pacotes necessários do NLTK
import nltk
nltk.download("punkt")
nltk.download("vader_lexicon")
Processamento de Linguagem Falada em Python

Análise de sentimento com VADER

# Importar a classe de análise de sentimento
from nltk.sentiment.vader import SentimentIntensityAnalyzer

# Criar instância de análise de sentimento sid = SentimentIntensityAnalyzer()
# Testar a análise em um texto negativo print(sid.polarity_scores("This customer service is terrible."))
{'neg': 0.437, 'neu': 0.563, 'pos': 0.0, 'compound': -0.4767}
Processamento de Linguagem Falada em Python

Análise de sentimento em texto transcrito

# Transcrever o canal do cliente de call_3
call_3_channel_2_text = transcribe_audio("call_3_channel_2.wav")
print(call_3_channel_2_text)
"hey Dave is this any better do I order products are currently on July 1st and I haven't 
received the product a three-week step down this parable 6987 5"
# Análise de sentimento no canal do cliente de call_3
sid.polarity_scores(call_3_channel_2_text)
{'neg': 0.0, 'neu': 0.892, 'pos': 0.108, 'compound': 0.4404}
Processamento de Linguagem Falada em Python

Sentença por sentença

call_3_paid_api_text = "Okay. Yeah. Hi, Diane. This is paid on this call and obvi..."
# Importar o tokenizador de sentenças
from nltk.tokenize import sent_tokenize

# Encontrar o sentimento de cada sentença for sentence in sent_tokenize(call_3_paid_api_text): print(sentence) print(sid.polarity_scores(sentence))
Processamento de Linguagem Falada em Python

Sentença por sentença

Okay.
{'neg': 0.0, 'neu': 0.0, 'pos': 1.0, 'compound': 0.2263}
Yeah.
{'neg': 0.0, 'neu': 0.0, 'pos': 1.0, 'compound': 0.296}
Hi, Diane.
{'neg': 0.0, 'neu': 1.0, 'pos': 0.0, 'compound': 0.0}
This is paid on this call and obviously the status of my orders at three weeks ago, 
and that service is terrible.
{'neg': 0.129, 'neu': 0.871, 'pos': 0.0, 'compound': -0.4767}
Is this any better?
{'neg': 0.0, 'neu': 0.508, 'pos': 0.492, 'compound': 0.4404}
Yes...
Processamento de Linguagem Falada em Python

Hora de codar!

Processamento de Linguagem Falada em Python

Preparing Video For Download...