The content of this post is written in a hurry. Please feel free to contact me at the bottom of page.
The idea here is to build a graph of synonyms and to use it to simplify a word cloud.
The simplification of the wordle is done by combining all words that are at a distance less than an adjustable threshold.
The first step is to construct a graph of synonyms from a database. For this, a recursive function is used. It takes a word as an argument. It recovers its synonyms and synonyms of its synonyms and so on. Recursion depth depth is adjustable.
Here depth is set to 1 to accelerate the download.
get_distance(a, b) can then be used to return the distance between two words on the graph.
This distance function is then used to merge words that are within a distance lower than a threshold set by the user.