快速回顧 Google 的評論
你決定建立 Google 正向與負向評論的 comparison.cloud(),好和 Amazon 做比較。這能讓你快速掌握關鍵詞,而不必像前幾個練習那樣花很多時間細看 Amazon 的評論。
我們已提供語料庫 all_goog_corpus,其中包含 500 筆正向與 500 筆負向的 Google 評論。接下來你會清理語料庫,並建立一個比較雲,對照正反兩類評論中的常見用詞。
本練習屬於課程
R 的 Bag-of-Words 文本探勘
練習說明
包含 Google 正反面評論的 all_goog_corpus 物件,已載入到你的工作空間。
- 使用預先定義好的
tm_clean()函式清理all_goog_corpus,建立all_goog_corp。 - 將
all_goog_corp轉換為 term-document matrix,建立all_tdm。 - 將
all_tdm轉換為矩陣,建立all_m。 - 用
all_m建立comparison.cloud()。將max.words設為100。colors參數已為你指定。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create all_goog_corp
___ <- ___
# Create all_tdm
___ <- ___
# Create all_m
___ <- ___
# Build a comparison cloud
___(___,
max.words = ___,
colors = c("#F44336", "#2196f3"))