{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Minimal Example\n\nGenerating a square wordcloud from the US constitution using default arguments.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import os\n\nfrom os import path\nfrom wordcloud import WordCloud\n\n# get data directory (using getcwd() is needed to support running example in generated IPython notebook)\nd = path.dirname(__file__) if \"__file__\" in locals() else os.getcwd()\n\n# Read the whole text.\ntext = open(path.join(d, 'werewolf.txt')).read()\n\n# Generate a word cloud image\nwordcloud = WordCloud(width=1600,height=900).generate(text)\n\n# Display the generated image:\n# the matplotlib way:\nimport matplotlib.pyplot as plt\nplt.imshow(wordcloud, interpolation='bilinear')\nplt.axis(\"off\")\n\nstop_words = {\"wouldn't\", 'between', \"why's\", 'know', 'over', \"you'll\", \"we'd\",\n\"shouldn't\", 'these', 'until', 'himself', 'no', \"aren't\", 'too', \"doesn't\",\n\"here's\", 'monsterdondoublefeature', 'or', 'theirs', \"he'll\", 'very', \"you're\",\n\"hasn't\", \"when's\", 'above', 'does', 'off', \"where's\", 'under', \"hadn't\",\n'film', \"didn't\", 'it', 'any', 'he', 'http', 'such', 'got', 'wolfen1981', 'be',\n'this', 'to', \"we're\", \"who's\", 'howling11985', 'www', 'a', 'not', \"he'd\",\n'ours', 'you', 'his', 'would', 'then', \"there's\", 'out', 'so', 'my', \"i'm\",\n'was', 'after', 'whom', 'we', 'your', 'all', 'about', 'ever', 'had', 'how',\n'hers', 'other', 'up', \"i'll\", \"i've\", 'during', 'therefore', 'while', \"we've\",\n\"she's\", 'can', 'their', \"don't\", 'since', 'did', 'once', \"she'd\", 'they',\n'than', 'like', 'good', \"you've\", \"they'd\", 'are', 'her', \"you'd\", 'ourselves',\n'movie', 'themselves', 'really', 'cannot', 'she', 'more', 'however', 'do',\n'going', 'when', 'with', 'our', \"we'll\", 'com', 'have', 'the', 'yeah', \"let's\",\n'those', 'them', \"wasn't\", 'which', 'why', 'yourselves', 'been', 'who', 'being',\n'most', 'get', \"mustn't\", \"what's\", 'also', 'me', 'watch', 'its', 'again',\n\"haven't\", \"she'll\", 'yours', 'that', 'as', 'before', 'hence', 'of',\n'monstermiru', \"they're\", 'few', 'were', 'now', \"isn't\", 'one', 'both', 'well',\n\"weren't\", 'could', 'if', \"how's\", 'there', 'am', 'because', 'see', 'further',\n'wulfen1981', 'is', 'ought', 'herself', \"they've\", 'i', 'own', 'into', 'what',\n'same', 'guy', 'otherwise', 'yourself', \"couldn't\", 'monsterdon', \"it's\", \"i'd\",\n'wrongwolfen', 'nor', 'from', 'by', 'should', 'an', 'some', 'myself', 'where',\n'down', 'shall', 'else', 'at', 'for', 'here', 'movies', 'against', 'through',\n\"they'll\", 'in', 'on', \"that's\", 'has', \"he's\", 'doing', \"won't\", 'but', 'r',\n'him', 'films', 'itself', 'and', 'having', 'each', 'only', \"can't\", 'k', 'just',\n\"shan't\", 'below'}\n\n# lower max_font_size\nwordcloud = WordCloud(max_font_size=40,\n    stopwords=stop_words,\n).generate(text)\nplt.figure(figsize=(13, 9))\nplt.imshow(wordcloud, interpolation=\"bilinear\")\nplt.axis(\"off\")\nplt.savefig('werewolf.png', format=\"png\")\n\n# The pil way (if you don't have matplotlib)\n# image = wordcloud.to_image()\n# image.show()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.13.5"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}