開始使用免費開始

推文的文字雲

在這個練習中,你要用一份 Twitter 資料的樣本繪製文字雲,內容是旅客對航空公司的情緒表達。我們已經為你建立了字串 text_tweet,其中包含 1,000 位使用者在 Twitter 上分享的訊息。

第一步,先在不移除停用詞的情況下建立文字雲;第二步,再在移除停用詞後建立相同的文字雲作比較。

你也可以先瀏覽並熟悉 text_tweet 清單的內容。

本練習屬於課程

Python 情感分析

檢視課程

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Import the word cloud function 
from ____ import ____ 

# Create and generate a word cloud image
my_cloud = ____(background_color='white').____(text_tweet)

# Display the generated wordcloud image
plt.imshow(my_cloud, interpolation='bilinear') 
plt.axis("off")

# Don't forget to show the final image
plt.show()
編輯並執行程式碼