A simple Jupyter (Lab/Notebook) wrapper of Jason Davies d3 JS wordcloud generator https://www.jasondavies.com/wordcloud/
pip install d3wordcloud
Input: text Output: HTML File export i.e.
import d3wordcloud as d3wc
d3wc.save_wordcloud(df.topics.unique()[2])
You can then load this in gradio using Markdown embedded as a link or try using gr.HTML(). A custom iframe should work too
Input: text, boolean for show_settings Output: An interactive SVG wordcloud right in your Jupyter Notebook (or Jupyter Lab).
import d3wordcloud as d3wc
d3wc.display_wordcloud(sample_data, show_settings=False)
sample_data
is a space-separated string, e.g."energy fossil fuel EU"
show_settings
shows the original settings for interactive control in your notebook, just like in the original version
If you'd like to use all the customization the library offers, either use the manual mode or build a modified wheel yourself.
For the manual mode, simply copy the manual
folder with the two files to your working directory and edit the html template directly.
git clone https://github.com/do-me/d3wordcloud.git
cd d3wordcloud
python setup.py sdist
tar tzf dist/d3wordcloud-0.0.1.tar.gz
python setup.py bdist_wheel sdist
cd dist
pip install d3wordcloud-0.0.1-py3-none-any.whl
Uninstalling is as easy as
pip uninstall d3wordcloud-0.0.1-py3-none-any.whl
If you are using a virtual env (like conda env) and the wordcloud SVG is not showing it is probably related to a Jupyter bug. A possible workaround is working in just one notebook at a time
- add probabilities (percentage) parameter so that we can fit LDA models and the top words percentages to control the size of each word
- Port all the settings for full control in Python.