Package: generatewordcloud
A simple Python script to generate a square wordcloud from one (or more) text file(s).
Supporting both Python 2 and 3 (2.7+ and 3.4+).Based on the greatword_cloudmodule by@amueller.How to use it?1.RequirementsThe usual modulematplotlibis needed for the plotting,docoptis needed for the command line interface,
andword_cloudis needed for the actual work (generating the cloud of words after reading the files).The required Python (2 or 3) modules can be installed withpip, either directly:# Directly:sudopipinstallmatplotlibdocoptword_cloudOr with therequirements.txtfile:sudopipinstall-rrequirements.txtNote: ifansicolortagsis
available, it will be used to print nice colors in the help and during the generation of word clouds.2. InstallationClone the repository, copy thescript (generate-word-cloud.py)somewhere in yourPATH(e.g.,~/.local/bin/).You can also just download the script itself:$wgethttps://raw.githubusercontent.com/Naereen/generate-word-cloud.py/master/generate-word-cloud.py$cpgenerate-word-cloud.py/path/to/a/directory/in/your/PATH/Note: The script isalsoavailable fromPyPI:pypi.python.org/pypi/generatewordcloud.
You can install it usingpip.$sudopipinstallgeneratewordcloud3. UsageHelp:$generate-word-cloud.py--helpFrom one or two filesGenerate a wordcloud from twotxtfiles in the current directory,
save it towordcloud_txt.png.$generate-word-cloud.py-o./wordcloud_txt.png./file1.txt./file2.txtGenerate a wordcloud from the textfilehamlet.txt(~ 8000 lines),
saving tohamlet.png:$generate-word-cloud.py-o./hamlet.png./hamlet.txt(It should work on pretty big text files without any issue.)Other examplesFrom a lot of Python scripts (~ 200)From a lot of Bash scripts (~ 150)From a lot of LaTeX files (~ 180)Meta exampleGenerate a wordcloud from theREADME.mdandgenerate-word-cloud.pyfilesof this
very project, save it towordcloud_meta.png!$generate-word-cloud.py-o./wordcloud_meta.png./*.md./*.pyFeatures[x] Support one or more input file(s), will cleanly skip any file it
fails to find or fails to read,[x] Custom output file, won’t be overwritten (except with-fflag),[x] Nice command line interface
(argparsepowered). I switched todocoptafter realizing how awesome it is![x] Has a command line option for every important parameter (max nb
of words, width, height etc).[x] Input filenames with spaces in their name were seen as several
files (e.g.this file.txt), FIXED with the switch todocopt.Complete documentation (--help)$ generate-word-cloud.py -h | --help
Usage:
  generate-word-cloud.py [-s | --show] [-f | --force] [-o OUTFILE | --outfile=OUTFILE]
                         [-t TITLE | --title=TITLE] [-m MAX | --max=MAX]
                         [-w WIDTH | --width=WIDTH] [-H HEIGHT | --height=HEIGHT]
                         INFILE...
  generate-word-cloud.py (-h | --help)
  generate-word-cloud.py (-v | --version)

Options:
  -h --help            Show this help message and exit.
  -v --version         Show program's version number and exit.
  -s --show            Show the image but do not save it [default False].
  -f --force           Force to write the image, even if present (default is to ask before overwriting an existing file) [default False].
  -o OUTFILE --outfile=OUTFILE
                       Filename for the generated image [default 'wordcloud.png'].
  -t TITLE --title=TITLE
                       Title for the image [default None].
  -m MAX --max MAX
                       Max number of words to display on the cloud word [default 150].
  -w WIDTH --width WIDTH
                       Width of the generate image [default 400].
  -H HEIGHT --height HEIGHT
                       Height of the generate image [default 300].
  INFILE               A text file to read.TODO[x] Start it, fromthis example,[x] Run it on some interesting examples, embed them here (as images),[X] Check on weird encodings? (i.e., not UTF-8). It works fine![X] Test it against :closed_book: VERY large files (million of line)
? It works fine, slowly but fine.[X] Test it against LOTS of files (several thousands) ? It
works fine, slowly but fine.[X] Publish it on PyPI: it is available atpypi.python.org/pypi/generatewordcloud/.[ ] Write a small article about it formy blog.Knows issues[ ] Only tested on (X)Ubuntu (15.10), but it should work on other
GNU/Linux distribution and Mac OS X (and probably Windows), if they
supportdocoptand has bothdocoptandword_cloudinstalled.Unknown issues?Use the issue trackerto notify me of a bug!AboutWhy write this script?There already is a lot ofgood cloud word generator online, e.g.wordle.net.I wanted a way to visualize the major keywords of Bash and Python (my
twofavorite programming languages) and of Markdown/Strapdown, reStructuredText and LaTeX (my favorite typeset documents system),The original projectword_cloudseemed cool. And it is. Great job@amueller!Clouds of words are interesting! And Python is awesome!AuthorLilian Besson (Naereen).License ?This plug-in is published under the terms of theGPLv3 License(fileLICENSE.txt), ©Lilian Besson, 2016.