Cuvinte de oprire

Analiza sentimentelor în Python

Violeta Misheva

Data Scientist

Ce sunt cuvintele de oprire și cum se identifică?

Cuvinte de oprire: apar frecvent și nu sunt considerate informative

  • Liste de cuvinte de oprire în majoritatea limbilor

      {'the', 'a', 'an', 'and', 'but', 'for', 'on', 'in', 'at' ...}
    
  • Contextul contează

      {'movie', 'movies', 'film', 'films', 'cinema'}
    
Analiza sentimentelor în Python

Cuvinte de oprire în nori de cuvinte

  • Nor de cuvinte fără eliminarea cuvintelor de oprire Nor de cuvinte fără eliminarea cuvintelor de oprire
  • Nor de cuvinte cu cuvintele de oprire eliminate Nor de cuvinte cu cuvintele de oprire eliminate
Analiza sentimentelor în Python

Eliminarea cuvintelor de oprire din nori de cuvinte

# Import libraries
from wordcloud import WordCloud, STOPWORDS
import matplotlib.pyplot as plt
# Define the stopwords list
my_stopwords = set(STOPWORDS)
my_stopwords.update(["movie", "movies", "film", "films", "watch", "br"])
# Generate and show the word cloud
my_cloud = WordCloud(background_color='white', stopwords=my_stopwords).generate(name_string)
plt.imshow(my_cloud, interpolation='bilinear')
Analiza sentimentelor în Python

Cuvinte de oprire în BOW

from sklearn.feature_extraction.text import CountVectorizer, ENGLISH_STOP_WORDS
# Define the set of stop words
my_stop_words = ENGLISH_STOP_WORDS.union(['film', 'movie', 'cinema', 'theatre'])
vect = CountVectorizer(stop_words=my_stop_words) 
vect.fit(movies.review)
X = vect.transform(movies.review)
Analiza sentimentelor în Python

Să exersăm!

Analiza sentimentelor în Python

Preparing Video For Download...