前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >在SAP分析云里利用词云技术显示大段文本里的关键词

在SAP分析云里利用词云技术显示大段文本里的关键词

作者头像
Jerry Wang
发布2020-04-13 12:04:49
4920
发布2020-04-13 12:04:49
举报

大段的聊天记录存储于csv文件的text列,生成词云的原理在Jerry的文章 在SAP分析云里根据业务数据绘制词云(Word Cloud) 里有过介绍。

生成的效果见下图:

R脚本源代码:

代码语言:javascript
复制
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"))
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-04-10 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档