Tiêu chí tần suất khác nhau

Khai phá văn bản với Bag-of-Words trong R

Ted Kwartler

Instructor

Trọng số thuật ngữ

  • Tần suất thuật ngữ mặc định = đếm từ đơn giản
  • Từ xuất hiện nhiều có thể che mờ insight
  • Điều chỉnh trọng số bằng TfIdf
  • Từ xuất hiện ở nhiều tài liệu sẽ bị giảm trọng số

đám mây từ 2

Khai phá văn bản với Bag-of-Words trong R

Trọng số thuật ngữ

# 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

Khai phá văn bản với Bag-of-Words trong R

Giữ lại siêu dữ liệu tài liệu

# Ensure the first 2 columns are doc_id & text
names(tweets)[1:2] <- c('doc_id','text')

# Create VCorpus including metadata
test_corpus <- VCorpus(DataframeSource(tweets))
# Clean and view results
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
Khai phá văn bản với Bag-of-Words trong R

Hãy luyện tập!

Khai phá văn bản với Bag-of-Words trong R

Preparing Video For Download...