私はあなたがテキストマイニングの練習を手伝うことができればと思っていました。私は「AAPL」のつぶやきに興味があり、APIから500個のつぶやきを引き出すことができました。私は自分自身でいくつかのハードルをクリアすることができましたが、最後の部分に助けが必要です。何らかの理由で、tmパッケージがストップワードを削除していません。あなたは見てみて、問題が何であるか見てみることができますか?顔文字は問題を引き起こしていますか?ストックツイート、テキストマイニング、絵文字Erros
Term_Frequencyをプロットした後、最も頻度の高い用語は、 "AAPL"、 "アップル"、 "iPhone"、 "価格" "株式" 事前に
感謝です! "AAPL" と "AAPLが" 別の文字列であるので、
Munckinn
transform into dataframe
tweets.df <- twListToDF(tweets)
#Isolate text from tweets
aapl_tweets <- tweets.df$text
#Deal with emoticons
tweets2 <- data.frame(text = iconv(aapl_tweets, "latin1", "ASCII", "bye"), stringsAsFactors = FALSE)
#Make a vector source:
aapl_source <- VectorSource(tweets2)
#make a volatile corpus
aapl_corpus <- VCorpus(aapl_source)
aapl_cleaned <- clean_corpus(aapl_source)
#create my list to remove words
myList <- c("aapl", "apple", "stock", "stocks", stopwords("en"))
#clean corpus function
clean_corpus <- function(corpus){
corpus <- tm_map(corpus, stripWhitespace, mc.cores = 1)
corpus <- tm_map(corpus, removePunctuation, mc.cores = 1)
corpus <- tm_map(corpus, removeWords, myList, mc.cores = 1)
return(corpus)
}
#clean aapl corpus
aapl_cleaned <- clean_corpus(aapl_corpus)
#convert to TDM
aapl.tdm <- TermDocumentMatrix(aapl_cleaned)
aapl.tdm
#Convert as Matrix
aapl_m <- as.matrix(aapl.tdm)
#Create Frequency tables
term_frequency <- rowSums(aapl_m)
term_frequency <- sort(term_frequency, decreasing = TRUE)
term_frequency[1:10]
barplot(term_frequency[1:10])
その可能性が高いです。あなたのコーパスの清掃手続きのどこにいても、私は「tolower」を見ません。 2番目の '' VCorpus'は 'content_transformer'がコーパスではなくベクトルを返すので、IIRCは' corpus < - tm_map(corpus、content_transformer(tolower)) 'と' corpus < - VCorpus(corpus) 'を追加する必要があります。 – emilliman5