matlab可以使用词云分析吗,Word Cloud (词云) - Matlab


今天要总结的是 Word Cloud 最后一个部分了,用 Matlab 来创建 word cloud。Matlab R2018b 已经提供 [wordcloud](https://www.mathworks.com/help/matlab/ref/wordcloud.html) 函数可以直接生成词云了。


##### >> Create Word Cloud via Matlab


准备文本。

不多说了,懒人继续用上次那个 Word Cloud History.txt 的文本吧。

读取并清洗数据文本。

%read txt as a string

text = string(fileread('C:\Users\yuki\Desktop\WordCloudHistory.txt'));

%delete puchuation

punctuationCharacters = ["." "?" "!" "," ";" ":"];

text = replace(text,punctuationCharacters," ");

%convert a string to array

words = split(join(text));

%delete the words has less than 5 characters, which are problely stop words

words(strlength(words)<5) = [];

%change all words to lowercase

words = lower(words);

计算词频并生成数组。

%calculate the frequencies for every word

[numOccurrences,uniqueWords] = histcounts(categorical(words));

生成 word cloud。

figure

%set properties for word cloud

wordcloud(uniqueWords,numOccurrences,'Shape', "rectangle", 'MaxDisplayWords', 200);

title("Word Cloud History")

d2913bae70ff7cf7da117f7c3945e080.png


##### >> Notes


Matlab 也有插件可以直接生成词云,操作简单,不用编程,哈哈。

既然已经说了各种可以创建词云的方法,那么就顺便总结一下什么方法好用方便不花钱。

ToolEasy UseFreeNeed Script
Python Clear document, powerful text mining library Yes Yes
JavaScript Need to extract array by own, and need to find a way to save the image Yes Yes
R Clear document, powerful text mining library Yes Yes
Matlab Clear document, interactive interface No Optional


##### >> Sample Code



##### >> Related Blogs


1. [Word Cloud (词云) - Python](https://www.cnblogs.com/yukiwu/p/10967037.html) 2. [Word Cloud (词云) - JavaScript](https://www.cnblogs.com/yukiwu/p/10968816.html) 3. [Word Cloud (词云) - R](https://www.cnblogs.com/yukiwu/p/10969250.html)
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值