Stop words

Sentiment Analysis con Python

Violeta Misheva

Data Scientist

Che cosa sono le stop words e come trovarle?

Stop words: parole troppo frequenti e poco informative

  • Elenchi di stop words in molte lingue

      {'the', 'a', 'an', 'and', 'but', 'for', 'on', 'in', 'at' ...}
    
  • Il contesto conta

      {'movie', 'movies', 'film', 'films', 'cinema'}
    
Sentiment Analysis con Python

Stop words con le word cloud

  • Word cloud senza rimuovere le stop words Word cloud senza rimuovere le stop words
  • Word cloud con stop words rimosse Word cloud con stop words rimosse
Sentiment Analysis con Python

Rimuovere le stop words dalle word cloud

# 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')
Sentiment Analysis con Python

Stop words con 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)
Sentiment Analysis con Python

Esercitiamoci!

Sentiment Analysis con Python

Preparing Video For Download...