在这本书关于 tydy-text 之后获得 n-gram:http: //tidytextmining.com/ngrams.html
编码:
library(tidyr)
bigrams_separated <- austen_bigrams %>%
separate(bigram, c("word1", "word2"), sep = " ")
bigrams_filtered <- bigrams_separated %>%
filter(!word1 %in% stop_words$word) %>%
filter(!word2 %in% stop_words$word)
# new bigram counts:
bigram_counts <- bigrams_filtered %>%
count(word1, word2, sort = TRUE)
我收到一个错误:
Warning: Error in : 'sep' is not an exported object from 'namespace:dplyr'