fork download
  1. clean.text <- function(x)
  2. {
  3. # remove rt
  4. x <- gsub("rt\\s", "", x)
  5. # remove at
  6. x <- gsub("@\\w+", "", x)
  7. x <- gsub("\\b-\\b(*SKIP)(*F)|[[:punct:]]", "", x, perl=TRUE)
  8. x <- gsub("[[:digit:]]+", "", x)
  9. # remove http
  10. x<- gsub("http\\w+", "", x)
  11. x <-gsub("\\h{2,}", "", x, perl=TRUE)
  12. x<- trimws(x)
  13. x<- gsub("[^[:alnum:][:space:]'-]", " ", x)
  14. return(x)
  15. }
  16. my_text <- " accident-prone http://w...content-available-to-author-only...e.com rt "
  17. new_text <- clean.text(my_text)
  18. new_text
Success #stdin #stdout 0.22s 183680KB
stdin
Standard input is empty
stdout
[1] "accident-prone"