zoukankan      html  css  js  c++  java
  • Word Cloud (词云)


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

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

    1. 读取并清洗数据文本。
    %read txt as a string
    text = string(fileread('C:UsersyukiDesktopWordCloudHistory.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);
    
    1. 计算词频并生成数组。
    %calculate the frequencies for every word
    [numOccurrences,uniqueWords] = histcounts(categorical(words));
    
    1. 生成 word cloud。
    figure
    %set properties for word cloud
    wordcloud(uniqueWords,numOccurrences,'Shape', "rectangle", 'MaxDisplayWords', 200);
    title("Word Cloud History")
    

    Word Cloud Maltab


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

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

    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

    download here


    ##### >> 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)
    作者:Yuki
    本文版权归作者和博客园所有,欢迎转载,转载请标明出处(附上博客链接)。 如果您觉得本篇博文对您有所收获,请点击右下角的 [推荐],谢谢!

    关注我的公众号,不定期更新学习心得
  • 相关阅读:
    归并两路有序链表
    [转]两种高性能I/O设计模式(Reactor/Proactor)的比较
    linux 静态库使用经验
    系统性能调优经验
    编译-O 选项对性能提升作用
    [转]Linux shell中的那些小把戏
    shell函数传递带空格的参数
    标题清洗引发的算法(两个字符串的最长公共子串)
    正则表达式之Matcher类中group方法
    ConcurrentHashMap JDK 1.6 源码分析
  • 原文地址:https://www.cnblogs.com/yukiwu/p/10971998.html
Copyright © 2011-2022 走看看