R로 배우는 Bag-of-Words 텍스트 마이닝
Ted Kwartler
Instructor
# 커피 트윗 첫 2개만 사용
tweets$text[1:2]
[1] @ayyytylerb that is so true drink lots of coffee
[2] RT @bryzy_brib: Senior March tmw morning at 7:25 A.M. in the SENIOR lot. Get up early, make yo coffee/breakfast, cus this will only happen…
# 첫 2개 커피 트윗으로 유니그램 DTM 생성
unigram_dtm <- DocumentTermMatrix(text_corp)
unigram_dtm
<<DocumentTermMatrix (documents: 2, terms: 18)>>
Non-/sparse entries: 18/18
Sparsity : 50%
Maximal term length: 15
Weighting : term frequency (tf)
# RWeka 패키지 로드
library(RWeka)
# 바이그램 토크나이저 정의 tokenizer <- function(x) NGramTokenizer(x, Weka_control(min = 2, max = 2))# 바이그램 TDM 생성 bigram_tdm <- TermDocumentMatrix(clean_corpus(text_corp), control = list(tokenize = tokenizer)) bigram_tdm
<<DocumentTermMatrix (documents: 2, terms: 21)>>
Non-/sparse entries: 21/21
Sparsity : 50%
Maximal term length: 19
Weighting : term frequency (tf)
R로 배우는 Bag-of-Words 텍스트 마이닝