【发布时间】:2021-08-26 07:57:18
【问题描述】:
我正在使用语料库数据帧上的 quanteda 包,这是我使用的基本代码:
library(quanteda)
fmsi_des <- dfm(corpus_des, remove=stopwords("spanish"), verbose=TRUE,
remove_punct=TRUE, remove_numbers=TRUE)
但是,我有另一个停用词列表作为数据框,称为 stpw,我想考虑一下。
我试过了:
fmsi_des <- dfm(corpus_des, remove=stopwords("spanish","stpw"), verbose=TRUE,
remove_punct=TRUE, remove_numbers=TRUE)
停用词错误(“西班牙语”,“stpw”):未使用的参数(“stpw”)
然后我创建了一个列表,其中包含“西班牙语”的停用词 + stpw 的停用词:
all_stops <- c("bogota","vias","medellin","valle","departamento",stopwords("spanish"))
fmsi_des <- dfm(corpus_des, remove=stopwords("all_stops"), verbose=TRUE,
remove_punct=TRUE, remove_numbers=TRUE)
停用词错误(“all_stops”):没有可用于“all_stops”的停用词
我还用我的停用词创建了一个 txt 文件,以便尝试:
library(tm)
stopwords = readLines('stpw.txt')
x = fd$contract_description
x = removeWords(x,stopwords)
des <- subset(x, !is.na(x))
corpus_des <- corpus(des$fd.contract_description)
fmsi_des <- dfm(corpus_des, remove=stopwords("spanish"), verbose=TRUE,
remove_punct=TRUE, remove_numbers=TRUE)
警告信息: 在 readLines("stp.txt") 中:在 'stpw.txt' 中找到不完整的最后一行
gsub(sprintf("(*UCP)\b(%s)\b", paste(sort(words, reduction = TRUE)) 中的错误: 不正确的正则表达式 '(*UCP)\b(bogota|vias|medellin|valle|departamento|+)\b' 另外:警告信息: 在 gsub(sprintf("(*UCP)\b(%s)\b", paste(sort(words, reduction = TRUE), : PCRE 模式编译错误 “没有什么可重复的” 在'+)\b'
【问题讨论】:
-
也许这种方法可以帮助Quanteda phrase()
标签: r text-mining corpus stop-words quanteda