准备聊天记录
建议使用QQ聊天记录,导出txt格式
进行文本分词并可视化
install.packages("wordcloud2")
install.packages("jiebaR")
install.packages("jiebaRD")
library(wordcloud2)
library(jiebaRD)
library(jiebaR)
engine=worker(stop_word = 'cn_stopwords.txt')
segment("chat.txt",engine)
word=scan('chat.segment.2021-05-04_23_07_11.txt',sep='\n',what='',encoding="UTF-8")
word=gsub("\n","",word)#删除换行
word=gsub(" ","",word)#删除空格
word=gsub("[0-9]+?","",word)#删除日期
word=qseg[word]
word=freq(word)
word=word[word$freq>50,]
wordcloud2(word,fontFamily='宋体',color = 'random-dark',shape = 'star')