Kriteria frekuensi berbeda

Text Mining dengan Bag-of-Words di R

Ted Kwartler

Instructor

Bobot istilah

  • Frekuensi istilah default = hitung kata sederhana
  • Kata umum dapat menutupi wawasan
  • Sesuaikan bobot istilah dengan TfIdf
  • Kata yang muncul di banyak dokumen dikenai penalti

wordcloud2.png

Text Mining dengan Bag-of-Words di R

Bobot istilah

# Standard term weighting
tf_tdm <- TermDocumentMatrix(text_corp)
tf_tdm_m <- as.matrix(tf_dtm)
tf_tdm_m[505:510, 5:10]

tdf.png

# TfIdf weighting
tf_idf_tdm <- TermDocumentMatrix(text_corp, 
    control = list(weighting = weightTfIdf))
tf_idf_tdm_m <- as.matrix(tf_idf_dtm)
tf_tdm_m <- as.matrix(tf_dtm)

tfidf.png

Text Mining dengan Bag-of-Words di R

Mempertahankan metadata dokumen

# Pastikan 2 kolom pertama adalah doc_id & text
names(tweets)[1:2] <- c('doc_id','text')

# Buat VCorpus beserta metadata
test_corpus <- VCorpus(DataframeSource(tweets))
# Bersihkan dan lihat hasil
text_corpus <- clean_corpus(text_corpus)
content(text_corpus[[1]])
$content
[1] "ayyytylerb true drink lots coffee"
meta(text_corpus[[1]])
$meta
  id      : 1
  author  : thejennagibson
  date    : 8/9/2013 2:43
  language: en
Text Mining dengan Bag-of-Words di R

Ayo berlatih!

Text Mining dengan Bag-of-Words di R

Preparing Video For Download...