Bước 3: Tổ chức văn bản

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

Ted Kwartler

Instructor

Tổ chức văn bản với qdap

# qdap cleaning function
qdap_clean <- function(x) {
  x <- replace_abbreviation(x)
  x <- replace_contraction(x)
  x <- replace_number(x)
  x <- replace_ordinal(x)
  x <- replace_symbol(x)
  x <- tolower(x)
  return(x)
}
Khai phá văn bản với Bag-of-Words trong R

Tổ chức văn bản với tm

# tm cleaning function
tm_clean <- function(corpus) {
  tm_clean <- tm_map(corpus, removePunctuation)
  corpus <- tm_map(corpus, stripWhitespace)
  corpus <- tm_map(corpus, removeWords,
              c(stopwords("en"), "Google", "Amazon", "company"))
  return(corpus)
}
Khai phá văn bản với Bag-of-Words trong R

Làm sạch corpora của bạn

 

clean_corpora.png

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...