【发布时间】:2019-07-10 18:58:16
【问题描述】:
基于这个问题:Interpretation of dfm_weight(scheme='prop') with groups (quanteda)
如果我有这个功能:
plot_topterms = function(data,text_field,n,...){
corp=corpus(data,text_field = text_field) %>%
dfm(remove_numbers=T,remove_punct=T,remove=c(stopwords('english')),ngrams=1:2) %>%
dfm_weight(scheme ='prop') %>%
dfm_group(groups=...) %>%
dfm_replace(pattern=as.character(lemma$first),replacement = as.character(lemma$X1)) %>%
dfm_remove(pattern = c(paste0("^", stopwords("english"), "_"), paste0("_", stopwords("english"), "$")), valuetype = "regex") %>%
dfm_remove(toRemove)
freq_weight <- textstat_frequency(corp, n = n)
ggplot(data = freq_weight, aes(x = nrow(freq_weight):1, y = frequency)) +
geom_bar(stat='identity')+
facet_wrap(~ group, scales = "free") +
coord_flip() +
scale_x_continuous(breaks = nrow(freq_weight):1,
labels = freq_weight$feature) +
#scale_y_continuous(labels = scales::percent)+
theme(text = element_text(size=20))+
labs(x = NULL, y = "Relative frequency")
}
而且我没有传入分组变量,所以我执行以下操作:
plot_topterms(df,textField,n=10)
我得到一个组变量等于all 的输出。这应该相当于甚至没有正确的 dfm_group 行?如果是这样的话,如果我对单词fun 的相对频率为 60,这是否意味着 60% 的所有文档都包含该单词?
【问题讨论】: