문자열에서 dfm 문자를 생성하려고합니다. dfm이 선택할 수없는 문제는 "/" "-" "같은 구두점의 기능을 만들 수 있습니다." 또는 '. 대한문자로 된 dfm을 생성합니다.
require(quanteda)
dict = c('a','b','c','d','e','f','/',".",'-',"'")
dict <- quanteda::dictionary(sapply(dict, list))
x<-c("cab","baa", "a/de-d/f","ad")
x<-sapply(x, function(x) strsplit(x,"")[[1]])
x<-sapply(x, function(x) paste(x, collapse = " "))
mat <- dfm(x, dictionary = dict, valuetype = "regex")
mat <- as.matrix(mat)
mat
- "A/드-D/F", 나는 "/" "문자를 캡처 할 -."너무
- 이유이다 "" 기능은 행렬 역할을합니다. 어떻게 개별 기능으로 유지할 수 있습니까?
'tokens <- tokenize (x, what = "character")와 비슷합니다. 매트 <- dfm (토큰, 사전 = dict, valueetype = "고정")'? 정규식 ("regex")에서'.'는 모든 문자를 나타냅니다. – lukeA
감사합니다. 이것은 내가 찾고 있었던 바로 그 것이다. – SuperSatya