【发布时间】:2018-04-19 04:39:47
【问题描述】:
我有一个包含 60000 行/短语的数据框,我想将其用作停用词并从文本中删除。
我使用 tm 包,并在读取包含停用词列表的 csv 文件后使用这一行:
corpus <- tm_map(corpus, removeWords, df$mylistofstopwords)
但我收到此错误:
In addition: Warning message:
In gsub(sprintf("(*UCP)\\b(%s)\\b", paste(sort(words, decreasing = TRUE), :
PCRE pattern compilation error
'regular expression is too large'
at ''
有什么问题是因为列表太大了吗?有什么我可以解决的吗?
【问题讨论】:
-
拆分列表并使用两个不同的
removeWords列表调用tm_map两次? -
@MrFlick 我试图泄露完整列表,但问题还是一样。我只尝试了前 2000 行并且它有效。我只是想知道是否有更高效的代码解决方案并且可能更快
-
这些词很长吗?
range(nchar(df$mylistofstopwords))是什么? -
@MrFlick 我尝试输入
range(nchar(df$mylistofstopwords)),但收到此错误:Error in nchar(df$mylistofstopwords) : 'nchar()' requires a character vector -
该列不是字符类吗?
class(df$mylistofstopwords)返回什么?也许range(nchar(as.character(df$mylistofstopwords)))’ or themean()`