2017-03-12 12 views

답변

0

min wordlength3입니다 matrix.` 내 임기 문서에서 한 글자 단어를 포함하기 위해 입력 인수로 포함해야한다 제어하는 ​​제안하십시오 . 기본값을 대체하려면 매개 변수를 control으로 지정해야합니다. 다음 코드를 확인하십시오.

library(tm) 
docs <- c("This is a text","When Will u start", "1 12 123") 
corpus <- Corpus(VectorSource(docs)) 

as.matrix(DocumentTermMatrix(corpus)) #words with length < 3 ('a','u','1','12') are excluded 
# Terms 
#Docs 123 start text this when will 
# 1 0  0 1 1 0 0 
# 2 0  1 0 0 1 1 
# 3 1  0 0 0 0 0 

as.matrix(DocumentTermMatrix(corpus, control = list(wordLengths=c(1,Inf)))) 
# Terms 
#Docs 1 12 123 a is start text this u when will 
# 1 0 0 0 1 1  0 1 1 0 0 0 
# 2 0 0 0 0 0  1 0 0 1 1 1 
# 3 1 1 1 0 0  0 0 0 0 0 0 
+1

감사합니다. Sandipan. 그것은 효과가 있었다. +1 – vaibhav