在SAP分析云里利用词云技术显示大段文本里的关键词
生活随笔
收集整理的這篇文章主要介紹了
在SAP分析云里利用词云技术显示大段文本里的关键词
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
大段的聊天記錄存儲(chǔ)于csv文件的text列,生成詞云的原理在Jerry的文章 在SAP分析云里根據(jù)業(yè)務(wù)數(shù)據(jù)繪制詞云(Word Cloud) 里有過介紹。
生成的效果見下圖:
R腳本源代碼:
library(wordcloud) library(tm) texts = as.character(sapTweets$text) texts <- iconv(texts, 'UTF-8', 'ASCII') texts <- gsub("http[s]?://[[:alnum:].\\/]+", "", texts) corpus <- Corpus(VectorSource(texts)) tdm <- TermDocumentMatrix(corpus, control = list(removePunctuation = TRUE, stopwords = c("amp", "will", "sap", "via", "can", "just", stopwords("english")), removeNumbers = TRUE, tolower = TRUE)) m <- as.matrix(tdm) word_freqs <- sort(rowSums(m), decreasing=TRUE) dm <- data.frame(word=names(word_freqs), freq=word_freqs) wordcloud(dm$word, dm$freq, scale = c(5, 1), max.words = 50, random.order = FALSE, rot.per = 0.2, use.r.layout = FALSE, colors=brewer.pal(8, "Dark2"))要獲取更多Jerry的原創(chuàng)文章,請關(guān)注公眾號"汪子熙":
總結(jié)
以上是生活随笔為你收集整理的在SAP分析云里利用词云技术显示大段文本里的关键词的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在SAP分析云里根据业务数据绘制词云(W
- 下一篇: 王者荣耀怎么克制夏洛特 克制夏洛特英雄介