[英]removeWords in the R tm package
我正在嘗試使用以下代碼在 R tm 包中使用 removeWords:
docs <- tm_map(docs, removeWords, stopwords("english"))
我收到以下錯誤消息:
Error in sort (words, decreasing = TRUE) :
argument "words" is missing, with no default
我在語料庫上嘗試的所有其他轉換都按預期工作(tolower、removeNumbers、stripWhitespace、removePunctuation 等...)但我無法讓 removeWords 正常工作,並且無法在網上找到有關此特定錯誤消息的任何信息.
我非常感謝您對可能導致此錯誤的原因有任何了解。
編輯:我的語料庫由所有位於同一文件夾中的 html 文檔組成。 我用來測試 removeWords 轉換的代碼如下:
setwd(“C:/folder”)
library(RCurl)
library(XML)
library (tm)
library (SnowballC)
docs <- Corpus(DirSource(“C:/folder”))
docs <- tm_map(docs, removePunctuation)
docs <- tm_map(docs, tolower)
docs <- tm_map(docs, removeNumbers)
docs <- tm_map(docs, removeWords, stopwords(“english”))
嘗試添加單詞刪除單詞功能。
例子:
corpus = tm_map(corpus, removeWords, c("apple", stopwords("english")))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.