BaşlayınÜcretsiz Başlayın

Compare Tidy Sentiment to Qdap Polarity

Here you will learn that differing sentiment methods will cause different results. Often you will simply need to have results align directionally although the specifics may be different. In the last exercise you created tidy_reviews which is a data frame of rental reviews without stopwords. Earlier in the chapter, you calculated and plotted qdap's basic polarity() function. This showed you the reviews tend to be positive.

Now let's perform a similar analysis the tidytext way! Recall from an earlier chapter you will perform an inner_join() followed by count() and then a pivot_wider().

Lastly, you will create a new column using mutate() and passing in positive - negative.

Bu egzersiz

Sentiment Analysis in R

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Using the get_sentiments() function with "bing" will obtain the bing subjectivity lexicon. Call the lexicon bing.
  • Since you already wrote this code in Chapter 2 simply enter in the lexicon object, bing, the new column name (polarity) and its calculation within mutate().
  • Lastly call summary() on the new object pos_neg. Although the values are different, after reviewing the mean, are most rental reviews similarly positive compared to using polarity()? Do you see "grade inflation?"

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Get the correct lexicon
bing <- ___

# Calculate polarity for each review
pos_neg <- tidy_reviews %>% 
  inner_join(___) %>%
  count(sentiment) %>%
  pivot_wider(names_from = sentiment, values_from = n, values_fill = 0) %>% 
  mutate(___ = ___ - ___)

# Check outcome
___
Kodu Düzenle ve Çalıştır