은 깔끔한 텍스트 마이닝 패키지 : (그래서 확인 종속 ...- 내가 scope
으로 언급
library(tidytext) # install.packages("tidytext")
library(tidyr) # install.packages("tidyr")
library(dplyr) # install.packages("dplyr")
dd <- data.frame(
text = c("hello how are you doing thank
you for helping me with this
problem","junk","junk"), stringsAsFactors = F)
WIH 가능한 방법입니다 단어 지평선 대한 매개 변수; 함수에 다음 코드를 설정하기 쉬운 : 귀하의 코멘트에 대해서는
scope=3
dd %>%
unnest_tokens(ngram, text, token = "ngrams", n = 1+scope) %>%
separate(ngram, paste("word",1:(scope+1),sep=""), sep = " ") %>%
filter(word1 %in% c("how")) %>% apply(.,1,paste, collapse= " ")
[1] "how are you doing"
: 경우
scope=2
dd %>%
unnest_tokens(ngram, text, token = "ngrams", n = 1+scope) %>%
separate(ngram, paste("word",1:(scope+1),sep=""), sep = " ") %>%
filter(word1 %in% c("how","me"))
# A tibble: 2 × 3
word1 word2 word3
<chr> <chr> <chr>
1 how are you
2 me with this
당신은 문자열을 끝내고 싶어, 당신은 예를 들어 ngrams, CF 두 번째 예제를 다시 축소해야 : 청크 (문자열) 당 청크 (문자열)를 작업하려면이 그룹을 명시 적으로 처리해야합니다. 여기 은 인스턴스에 대한 방법입니다 :
scope=2
subsets <-
dd %>%
mutate(id=1:length(text)) %>%
split(., .$id)
unlist(lapply(subsets, function(dd) {
dd %>%
unnest_tokens(ngram, text, token = "ngrams", n = 1+scope) %>%
separate(ngram, paste("word",1:(scope+1),sep=""), sep = " ") %>%
filter(word1 %in% c("how","problem")) %>%
apply(.,1,FUN=function(vec) paste(vec[-1],collapse=" "))
}))
1
"how are you"
별로 정규식 전문가 그러나 이것은 당신이 도움이 될 수 https://regex101.com/r/95g7yT/1 – digEmAll
당신이 만약 결과로보고 무엇을 기대 ''how '''와''''와 N = 3과 같이 두 개의 용어를 지정하십시오. 또한, 두 단어 사이의 거리가 3 단어보다 작 으면, "hello"와 "is"를 골랐는가? –
1 - 두 가지 용어 "방법"또는 "함께"및 N = 3 나는 생성하고 싶습니다 : "어떻게이 문제로하고 있습니다". 두 번째 용어 인 "with"의 결과는 문자열의 끝까지 단어를 유지합니다. 2 - 용어가 "안녕하세요"이고 "있는"경우, 나는 유지하고 싶습니다. "안녕하세요, 어떻게 감사하고 있습니까?"가능한 경우. – BEMR