Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 正则表达式错误消息-“;“内存不足”;_R - Fatal编程技术网

R 正则表达式错误消息-“;“内存不足”;

R 正则表达式错误消息-“;“内存不足”;,r,R,我一直在玩弄R的情绪分析功能,并不断遇到运行gsub函数时出现的错误。积极和消极的词表取自 在谷歌搜索了几次之后,我在R帮助列表中发现了一条关于这个错误的信息,但除此之外什么都没有。有人遇到过这个问题吗?发生了什么事?有解决办法吗 过去我在处理字符串时运行过类似的代码(使用gsub和stringer包),这是我第一次遇到这种类型的错误。此外,我试图通过在一组不同的字符串上编写类似的脚本来重现这个错误,而且效果很好 以下是错误消息: > pos_match <- str_c(vpos,

我一直在玩弄R的情绪分析功能,并不断遇到运行gsub函数时出现的错误。积极和消极的词表取自

在谷歌搜索了几次之后,我在R帮助列表中发现了一条关于这个错误的信息,但除此之外什么都没有。有人遇到过这个问题吗?发生了什么事?有解决办法吗

过去我在处理字符串时运行过类似的代码(使用gsub和stringer包),这是我第一次遇到这种类型的错误。此外,我试图通过在一组不同的字符串上编写类似的脚本来重现这个错误,而且效果很好

以下是错误消息:

> pos_match <- str_c(vpos, collapse = "|")
> neg_match <- str_c(vneg, collapse = "|")
> dat$positive <- as.numeric(str_detect(dat$Comment, pos_match))
> dat$negative <- as.numeric(str_detect(dat$Comment, neg_match))
Error: invalid regular expression, reason 'Out of memory'

>pos_match neg_match dat$positive dat$negative dat$negative我不知道整个解决方案,但我可以让您开始。我制作了这个社区维基,希望有人能填补空白

对于无效的正则表达式,要创建OR,需要将所有内容都括在括号中。例如,如果要匹配单词“a”、“an”或“the”,可以使用正则表达式字符串
(a | an | the)
。如果我有一个与正则表达式中的OR匹配的单词列表,我通常会使用以下内容:

mywords <- c("a", "an", "the")
mystring <- paste0("(", paste(mywords, collapse="|"), ")")

> mystring
[1] "(a|an|the)"

mywords您是在创建~6000
还是
运算符匹配-“|”<代码>位置匹配您的问题我没有答案,因为它不可复制,但您可能需要查看
qdap
包中的。你可能正在重新发明一些已经完成的东西。
tm
软件包还有一个
tm.plugin.touction
,这应该比构建巨型正则表达式要好一点。@Tylerinker谢谢!哇,你已经准备好做所有的工作了。
> dat$negative <- as.numeric(str_detect(dat$Comment, neg_match))
Error: invalid regular expression 'faced|faces|abnormal|abolish|abominable|abominably|abominate|abomination|abort|aborted|
dat = c("Hey guys I am Aliza Lomez...18 y.o. I need your likes please like my page and find love quotes, beauty tips and much more.Please like my page you will never regret thank u all\u0083 <3 <3 <3...",
        "Alexandra Saturn", "And that's what makes a Subaru a Subaru", "Missouri in a battleground....; meanwhile in southern California....", "What the Frisbee", "very cool !!!!", "Get a life", 
        "Try that with my GT!!!", "Did he make any money?", "Wo! WO! BSMITH THROWING DISCS WITH SUBARUS?!?! THIS IS SO AWESOME! SHOULD OF USED AN STI THO")
mywords <- c("a", "an", "the")
mystring <- paste0("(", paste(mywords, collapse="|"), ")")

> mystring
[1] "(a|an|the)"