步驟 1:文字雲與特徵建立
在整個練習中,你會使用 reviews 資料集的一個樣本。它包含 review 與 score 欄位。你可以在 IPython Shell 中自由探索。
第一步,你將只用正向評論來建立一個文字雲。字串 positive_reviews 已經為你建立,內容為前 100 則正向評論的串接結果。
第二步,你會為每則評論建立一個新的長度特徵,並把這個新特徵加入資料集。
繪製文字雲所需的所有函式都已為你匯入,同時也包含來自 nltk 模組的 word_tokenize 函式。
本練習屬於課程
Python 情感分析
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create and generate a word cloud image
cloud_positives = ____(background_color='white').____(positive_reviews)
# Display the generated wordcloud image
plt.___(cloud_positives, interpolation='bilinear')
plt.axis("off")
# Don't forget to show the final image
plt.show()