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

Comparing the sentiment of two strings

In this exercise, you will compare the sentiment of two different strings. A string called annak has been defined for you and it contains the first sentence of Anna Karenina. A second string called catcher has been created and it contains the first sentence of The Catcher in the Rye. Feel free to explore both in the IPython Shell.

Your task is again to detect the sentiment of each string - both their polarity and subjectivity. Which one has higher sentiment score? Did you expect that to be the case?

Bu egzersiz

Sentiment Analysis in Python

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

Egzersiz talimatları

  • Import the required function from the appropriate package.
  • Create a text blob object from the annak string.
  • Create a text blob from the catcher string as well.
  • Print out the polarity and subjectivity of each of the created blobs.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Import the required packages
____

# Create a textblob object 
blob_annak = ____(annak)
blob_catcher = ____(catcher)

# Print out the sentiment   
print('Sentiment of annak: ', ____.____)
print('Sentiment of catcher: ', ____.____)
Kodu Düzenle ve Çalıştır