【发布时间】:2019-01-27 05:02:19
【问题描述】:
我曾尝试使用 quanteda 来提取顶级特征,但结果是经过修改的单词,即“faulti”而不是“faulty”。这应该是预期的结果吗?
我已尝试在原始数据集中搜索排名靠前的特征关键字,但没有达到预期的匹配。
编辑:如果我为函数 dfm() 设置了选项 stem=FALSE,则关键词恢复为普通词。
library(quanteda)
corpus1 = corpus(as.character(training_data$Elec_rmk))
kwic(corpus1, 'faulty')
#[text25701, 4] Convertible roof sometime | faulty | . SD card missing.
#[text25701, 22] unavailable). Pilot lamp | faulty | .
dfm1 <- dfm(
corpus1,
ngrams = 1,
remove = stopwords("english"),
remove_punct = TRUE,
remove_numbers = TRUE,
stem = TRUE)
tf1 <- topfeatures(dfm1, n = 10)
tf1
# key words were modified/truncated words?
#faulti malfunct light damag miss cover rear loos lamp plate
# 562 523 454 337 331 325 295 259 250 238
library(stringr)
sum(str_detect(training_data$Elec_rmk, 'faulti')) # 0
sum(str_detect(training_data$Elec_rmk, 'faulty')) # 495
【问题讨论】: