Giter Club home page Giter Club logo

d3wordcloud's Introduction

d3wordcloud

A simple Jupyter (Lab/Notebook) wrapper of Jason Davies d3 JS wordcloud generator https://www.jasondavies.com/wordcloud/

image

Installation

pip install d3wordcloud

Usage

Function save_wordcloud()

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

Function display_wordcloud()

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

image

Settings

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.

Building the installable Python wheel yourself

  1. git clone https://github.com/do-me/d3wordcloud.git
  2. cd d3wordcloud
  3. python setup.py sdist
  4. tar tzf dist/d3wordcloud-0.0.1.tar.gz
  5. python setup.py bdist_wheel sdist
  6. cd dist
  7. 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

Troubleshooting

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

To Do

  • 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.

d3wordcloud's People

Contributors

do-me avatar 240db avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.