我正在尝试使用twitteR挖掘的推文创建一个wordcloud。我已经使用了包含推文sans格式的csv文件作为相同的输入。以下是我的代码:
library(tm)
library(plyr)
library(SnowballC)
library(wordcloud)
fk <-read.csv('onlyTweets.csv',colClasses="character",stringsAsFactors= FALSE, skipNul= TRUE)
fkCorpus<- Corpus(VectorSource(fk))
fkCorpus <- tm_map(fkCorpus,
content_transformer(function(x) iconv(x, to="", sub='byte')),
mc.cores=1)
fkCorpus <- tm_map(fkCorpus, content_transformer(tolower), lazy= TRUE, mc.cores= 1)
fkCorpus<- tm_map(fkCorpus, content_tranfformer(PlainTextDocument), lazy= TRUE,mc.cores= 1)
fkCorpus<- tm_map(fkCorpus, content_tranfformer(removePunctuation), lazy= TRUE, mc.cores=1)
fkCorpus<- tm_map(fkCorpus, content_tranfformer(removeNumbers), lazy= TRUE, mc.cores= 1)
fkCorpus <- tm_map(fkCorpus,removeWords , c(stopwords("english"),'the','flipkart','bigbillionsale','was'), lazy= TRUE, mc.cores=1)
fkCorpus<- tm_map(fkCorpus, stemDocument, lazy= TRUE,mc.cores= 1)
wordcloud(fkCorpus, max.words=75)#, random.order= FALSE)
我收到以下错误:
Error in UseMethod("meta", x) :
no applicable method for 'meta' applied to an object of class "try-error"
In addition: Warning messages:
1: In mclapply(x$content[i], function(d) tm_reduce(d, x$lazy$maps)) :
all scheduled cores encountered errors in user code
2: In mclapply(unname(content(x)), termFreq, control) :
all scheduled cores encountered errors in user code
我的sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.3 LTS
locale:
[1] LC_CTYPE=en_IN.UTF-8 LC_NUMERIC=C LC_TIME=en_IN.UTF-8
[4] LC_COLLATE=en_IN.UTF-8 LC_MONETARY=en_IN.UTF-8 LC_MESSAGES=en_IN.UTF-8
[7] LC_PAPER=en_IN.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_IN.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] wordcloud_2.5 RColorBrewer_1.1-2 SnowballC_0.5.1 plyr_1.8.3
[5] tm_0.6-2 NLP_0.1-8
loaded via a namespace (and not attached):
[1] Rcpp_0.12.2 twitteR_1.1.9 slam_0.1-32 grid_3.2.3 R6_2.1.2
[6] gtable_0.1.2 DBI_0.3.1 scales_0.3.0 ggplot2_2.0.0 httr_1.1.0
[11] rjson_0.2.15 tools_3.2.3 bit64_0.9-5 munsell_0.4.2 bit_1.1-12
[16] parallel_3.2.3 colorspace_1.2-6
我已经遇到了类似的问题,并且建议将 lazy = TRUE 和 mc.cores = 1 并使用 content_transformer 我可以,但没有一个答案奏效。请帮忙。
答案 0 :(得分:0)
我知道你可能已经找到了一种方法来自己做,但如果你没有,如果你还在尝试寻找同样的方法。请执行以下操作:
fkCorpus <- tm_map(fkCorpus,removeWords,stopwords("english"),lazy=TRUE, mc.cores=1)
fkCorpus <- tm_map(fkCorpus,removeWords,c("the","flipkart","bigbillionsale","was"),lazy=TRUE, mc.cores=1)
它应该工作:)如果它不起作用,最好让我知道!!