Stopwoorden

Sentimentanalyse in Python

Violeta Misheva

Data Scientist

Wat zijn stopwoorden en hoe vind je ze?

Stopwoorden: woorden die heel vaak voorkomen en weinig informatief zijn

  • Lijsten met stopwoorden bestaan voor de meeste talen

      {'the', 'a', 'an', 'and', 'but', 'for', 'on', 'in', 'at' ...}
    
  • Context is belangrijk

      {'movie', 'movies', 'film', 'films', 'cinema'}
    
Sentimentanalyse in Python

Stopwoorden met wordclouds

  • Wordcloud zonder stopwoorden te verwijderen Word cloud without removing stop words
  • Wordcloud met stopwoorden verwijderd Word cloud with stop words removed
Sentimentanalyse in Python

Stopwoorden uit wordclouds verwijderen

# 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')
Sentimentanalyse in Python

Stopwoorden met 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)
Sentimentanalyse in Python

Laten we oefenen!

Sentimentanalyse in Python

Preparing Video For Download...