Word Cloud
Draw a word cloud from a given text, possibly excluding some (most-frequent) words.
Examples
- Word cloud for words in Shakespheare's sonnets, excluding some most commonly used words.
::
let path = "./tests/imgs/wordcloud/shakespeare_sonnets.txt"
var fs: FileStream = FileStream(path)
fs.openFile()
var text = fs.readAllText()
fs.close()
var low_text = text.toAsciiLower()
let black_path = "./tests/imgs/wordcloud/en_blacklist.txt"
var bfs: FileStream = FileStream(black_path)
bfs.openFile()
var bl_text = bfs.readAllText()
bfs.close()
let bl_tokens = tokenize(bl_text)
wordcloud(low_text,bl_tokens)
Result:
.. image:: ../../../tests/imgs/wordcloud/wordcloud_1.png :align: center :width: 360
Methods
============================== =============================== Method Description ============================== =============================== wordcloud 1 method Draw a word cloud ============================== ===============================
Description
.. function:: wordcloud(text, black_list)
:param text: String
:param black_list: Array<String>
Draw a word cloud from given ``text``, excluding words in ``black_list``.