Step 3: Text organization

Text Mining with Bag-of-Words in R

Ted Kwartler

Instructor

Text organization with 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)
}
Text Mining with Bag-of-Words in R

Text organization with 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)
}
Text Mining with Bag-of-Words in R

Cleaning your corpora

 

clean_corpora.png

Text Mining with Bag-of-Words in R

Let's practice!

Text Mining with Bag-of-Words in R

Preparing Video For Download...