{
    "cells": [
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "# NRC Emotional Lexicon\n",
                "\n",
                "This is the [NRC Emotional Lexicon](http://saifmohammad.com/WebPages/NRC-Emotion-Lexicon.htm): \"The NRC Emotion Lexicon is a list of English words and their associations with eight basic emotions (anger, fear, anticipation, trust, surprise, sadness, joy, and disgust) and two sentiments (negative and positive). The annotations were manually done by crowdsourcing.\"\n",
                "\n",
                "I don't trust it, but everyone uses it."
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "<p class=\"reading-options\">\n  <a class=\"btn\" href=\"/upshot-trump-emolex/nrc-emotional-lexicon\">\n    <i class=\"fa fa-sm fa-book\"></i>\n    Read online\n  </a>\n  <a class=\"btn\" href=\"/upshot-trump-emolex/notebooks/NRC Emotional Lexicon.ipynb\">\n    <i class=\"fa fa-sm fa-download\"></i>\n    Download notebook\n  </a>\n  <a class=\"btn\" href=\"https://colab.research.google.com/github/littlecolumns/ds4j-notebooks/blob/master/upshot-trump-emolex/notebooks/NRC Emotional Lexicon.ipynb\" target=\"_new\">\n    <i class=\"fa fa-sm fa-laptop\"></i>\n    Interactive version\n  </a>\n</p>"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "### Prep work: Downloading necessary files\n",
                "Before we get started, we need to download all of the data we'll be using.\n",
                "* **NRC-emotion-lexicon-wordlevel-alphabetized-v0.92.txt:** NRC Emotional Lexicon - a list of English words and their associations with eight basic emotions and two sentiments\n"
            ]
        },
        {
            "cell_type": "code",
            "metadata": {},
            "source": [
                "# Make data directory if it doesn't exist\n",
                "!mkdir -p data\n",
                "!wget -nc https://nyc3.digitaloceanspaces.com/ml-files-distro/v1/upshot-trump-emolex/data/NRC-emotion-lexicon-wordlevel-alphabetized-v0.92.txt -P data"
            ],
            "outputs": [],
            "execution_count": null
        },
        {
            "cell_type": "code",
            "execution_count": 12,
            "metadata": {},
            "outputs": [],
            "source": [
                "import pandas as pd"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 26,
            "metadata": {},
            "outputs": [
                {
                    "data": {
                        "text/html": [
                            "<div>\n",
                            "<style scoped>\n",
                            "    .dataframe tbody tr th:only-of-type {\n",
                            "        vertical-align: middle;\n",
                            "    }\n",
                            "\n",
                            "    .dataframe tbody tr th {\n",
                            "        vertical-align: top;\n",
                            "    }\n",
                            "\n",
                            "    .dataframe thead th {\n",
                            "        text-align: right;\n",
                            "    }\n",
                            "</style>\n",
                            "<table border=\"1\" class=\"dataframe\">\n",
                            "  <thead>\n",
                            "    <tr style=\"text-align: right;\">\n",
                            "      <th></th>\n",
                            "      <th>word</th>\n",
                            "      <th>emotion</th>\n",
                            "      <th>association</th>\n",
                            "    </tr>\n",
                            "  </thead>\n",
                            "  <tbody>\n",
                            "    <tr>\n",
                            "      <th>0</th>\n",
                            "      <td>aback</td>\n",
                            "      <td>anger</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>1</th>\n",
                            "      <td>aback</td>\n",
                            "      <td>anticipation</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>2</th>\n",
                            "      <td>aback</td>\n",
                            "      <td>disgust</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>3</th>\n",
                            "      <td>aback</td>\n",
                            "      <td>fear</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>4</th>\n",
                            "      <td>aback</td>\n",
                            "      <td>joy</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>5</th>\n",
                            "      <td>aback</td>\n",
                            "      <td>negative</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>6</th>\n",
                            "      <td>aback</td>\n",
                            "      <td>positive</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>7</th>\n",
                            "      <td>aback</td>\n",
                            "      <td>sadness</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>8</th>\n",
                            "      <td>aback</td>\n",
                            "      <td>surprise</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>9</th>\n",
                            "      <td>aback</td>\n",
                            "      <td>trust</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>10</th>\n",
                            "      <td>abacus</td>\n",
                            "      <td>anger</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>11</th>\n",
                            "      <td>abacus</td>\n",
                            "      <td>anticipation</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "  </tbody>\n",
                            "</table>\n",
                            "</div>"
                        ],
                        "text/plain": [
                            "      word       emotion  association\n",
                            "0    aback         anger            0\n",
                            "1    aback  anticipation            0\n",
                            "2    aback       disgust            0\n",
                            "3    aback          fear            0\n",
                            "4    aback           joy            0\n",
                            "5    aback      negative            0\n",
                            "6    aback      positive            0\n",
                            "7    aback       sadness            0\n",
                            "8    aback      surprise            0\n",
                            "9    aback         trust            0\n",
                            "10  abacus         anger            0\n",
                            "11  abacus  anticipation            0"
                        ]
                    },
                    "execution_count": 26,
                    "metadata": {},
                    "output_type": "execute_result"
                }
            ],
            "source": [
                "filepath = \"data/NRC-Emotion-Lexicon-v0.92/NRC-emotion-lexicon-wordlevel-alphabetized-v0.92.txt\"\n",
                "emolex_df = pd.read_csv(filepath,  names=[\"word\", \"emotion\", \"association\"], skiprows=45, sep='\\t', keep_default_na=False)\n",
                "emolex_df.head(12)"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "Seems kind of simple. A column for a word, a column for an emotion, and whether it's associated or not. You see \"aback aback aback aback\" because there's a row for every word-emotion pair."
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "## What emotions are covered?\n",
                "\n",
                "Let's look at the 'emotion' column. What can we talk about?"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 27,
            "metadata": {},
            "outputs": [
                {
                    "data": {
                        "text/plain": [
                            "array(['anger', 'anticipation', 'disgust', 'fear', 'joy', 'negative',\n",
                            "       'positive', 'sadness', 'surprise', 'trust'], dtype=object)"
                        ]
                    },
                    "execution_count": 27,
                    "metadata": {},
                    "output_type": "execute_result"
                }
            ],
            "source": [
                "emolex_df.emotion.unique()"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 28,
            "metadata": {},
            "outputs": [
                {
                    "data": {
                        "text/plain": [
                            "negative        14182\n",
                            "trust           14182\n",
                            "anger           14182\n",
                            "anticipation    14182\n",
                            "sadness         14182\n",
                            "fear            14182\n",
                            "joy             14182\n",
                            "disgust         14182\n",
                            "positive        14182\n",
                            "surprise        14182\n",
                            "Name: emotion, dtype: int64"
                        ]
                    },
                    "execution_count": 28,
                    "metadata": {},
                    "output_type": "execute_result"
                }
            ],
            "source": [
                "emolex_df.emotion.value_counts()"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "## How many words does each emotion have?\n",
                "\n",
                "Each emotion doesn't have 14182 words associated with it, unfortunately! `1` means \"is associated\" and `0` means \"is not associated.\"\n",
                "\n",
                "We're only going to care about \"is associated.\""
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 29,
            "metadata": {},
            "outputs": [
                {
                    "data": {
                        "text/plain": [
                            "negative        3324\n",
                            "positive        2312\n",
                            "fear            1476\n",
                            "anger           1247\n",
                            "trust           1231\n",
                            "sadness         1191\n",
                            "disgust         1058\n",
                            "anticipation     839\n",
                            "joy              689\n",
                            "surprise         534\n",
                            "Name: emotion, dtype: int64"
                        ]
                    },
                    "execution_count": 29,
                    "metadata": {},
                    "output_type": "execute_result"
                }
            ],
            "source": [
                "emolex_df[emolex_df.association == 1].emotion.value_counts()"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "In theory things could be *kind of* angry or *kind of* joyous, but it doesn't work like that. If you want to spend a few hundred dollars on Mechnical Turk, though, *your own personal version can.*"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "## What if I just want the angry words?"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 30,
            "metadata": {},
            "outputs": [
                {
                    "data": {
                        "text/plain": [
                            "30          abandoned\n",
                            "40        abandonment\n",
                            "170             abhor\n",
                            "180         abhorrent\n",
                            "270           abolish\n",
                            "             ...     \n",
                            "141220       wrongful\n",
                            "141230        wrongly\n",
                            "141470           yell\n",
                            "141500           yelp\n",
                            "141640          youth\n",
                            "Name: word, Length: 1247, dtype: object"
                        ]
                    },
                    "execution_count": 30,
                    "metadata": {},
                    "output_type": "execute_result"
                }
            ],
            "source": [
                "emolex_df[(emolex_df.association == 1) & (emolex_df.emotion == 'anger')].word"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "## Reshaping\n",
                "\n",
                "You can also reshape the data in order to look at it a slightly different way"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 31,
            "metadata": {},
            "outputs": [
                {
                    "data": {
                        "text/html": [
                            "<div>\n",
                            "<style scoped>\n",
                            "    .dataframe tbody tr th:only-of-type {\n",
                            "        vertical-align: middle;\n",
                            "    }\n",
                            "\n",
                            "    .dataframe tbody tr th {\n",
                            "        vertical-align: top;\n",
                            "    }\n",
                            "\n",
                            "    .dataframe thead th {\n",
                            "        text-align: right;\n",
                            "    }\n",
                            "</style>\n",
                            "<table border=\"1\" class=\"dataframe\">\n",
                            "  <thead>\n",
                            "    <tr style=\"text-align: right;\">\n",
                            "      <th>emotion</th>\n",
                            "      <th>word</th>\n",
                            "      <th>anger</th>\n",
                            "      <th>anticipation</th>\n",
                            "      <th>disgust</th>\n",
                            "      <th>fear</th>\n",
                            "      <th>joy</th>\n",
                            "      <th>negative</th>\n",
                            "      <th>positive</th>\n",
                            "      <th>sadness</th>\n",
                            "      <th>surprise</th>\n",
                            "      <th>trust</th>\n",
                            "    </tr>\n",
                            "  </thead>\n",
                            "  <tbody>\n",
                            "    <tr>\n",
                            "      <th>0</th>\n",
                            "      <td>aback</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>1</th>\n",
                            "      <td>abacus</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>2</th>\n",
                            "      <td>abandon</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>3</th>\n",
                            "      <td>abandoned</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>4</th>\n",
                            "      <td>abandonment</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "  </tbody>\n",
                            "</table>\n",
                            "</div>"
                        ],
                        "text/plain": [
                            "emotion         word  anger  anticipation  disgust  fear  joy  negative  \\\n",
                            "0              aback      0             0        0     0    0         0   \n",
                            "1             abacus      0             0        0     0    0         0   \n",
                            "2            abandon      0             0        0     1    0         1   \n",
                            "3          abandoned      1             0        0     1    0         1   \n",
                            "4        abandonment      1             0        0     1    0         1   \n",
                            "\n",
                            "emotion  positive  sadness  surprise  trust  \n",
                            "0               0        0         0      0  \n",
                            "1               0        0         0      1  \n",
                            "2               0        1         0      0  \n",
                            "3               0        1         0      0  \n",
                            "4               0        1         1      0  "
                        ]
                    },
                    "execution_count": 31,
                    "metadata": {},
                    "output_type": "execute_result"
                }
            ],
            "source": [
                "emolex_words = emolex_df.pivot(index='word', columns='emotion', values='association').reset_index()\n",
                "emolex_words.head()"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "You can now pull out individual words..."
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 32,
            "metadata": {},
            "outputs": [
                {
                    "data": {
                        "text/html": [
                            "<div>\n",
                            "<style scoped>\n",
                            "    .dataframe tbody tr th:only-of-type {\n",
                            "        vertical-align: middle;\n",
                            "    }\n",
                            "\n",
                            "    .dataframe tbody tr th {\n",
                            "        vertical-align: top;\n",
                            "    }\n",
                            "\n",
                            "    .dataframe thead th {\n",
                            "        text-align: right;\n",
                            "    }\n",
                            "</style>\n",
                            "<table border=\"1\" class=\"dataframe\">\n",
                            "  <thead>\n",
                            "    <tr style=\"text-align: right;\">\n",
                            "      <th>emotion</th>\n",
                            "      <th>word</th>\n",
                            "      <th>anger</th>\n",
                            "      <th>anticipation</th>\n",
                            "      <th>disgust</th>\n",
                            "      <th>fear</th>\n",
                            "      <th>joy</th>\n",
                            "      <th>negative</th>\n",
                            "      <th>positive</th>\n",
                            "      <th>sadness</th>\n",
                            "      <th>surprise</th>\n",
                            "      <th>trust</th>\n",
                            "    </tr>\n",
                            "  </thead>\n",
                            "  <tbody>\n",
                            "    <tr>\n",
                            "      <th>2001</th>\n",
                            "      <td>charitable</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "    </tr>\n",
                            "  </tbody>\n",
                            "</table>\n",
                            "</div>"
                        ],
                        "text/plain": [
                            "emotion        word  anger  anticipation  disgust  fear  joy  negative  \\\n",
                            "2001     charitable      0             1        0     0    1         0   \n",
                            "\n",
                            "emotion  positive  sadness  surprise  trust  \n",
                            "2001            1        0         0      1  "
                        ]
                    },
                    "execution_count": 32,
                    "metadata": {},
                    "output_type": "execute_result"
                }
            ],
            "source": [
                "# If you didn't reset_index you could do this more easily\n",
                "# by doing emolex_words.loc['charitable']\n",
                "emolex_words[emolex_words.word == 'charitable']"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "...or individual emotions...."
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 33,
            "metadata": {},
            "outputs": [
                {
                    "data": {
                        "text/html": [
                            "<div>\n",
                            "<style scoped>\n",
                            "    .dataframe tbody tr th:only-of-type {\n",
                            "        vertical-align: middle;\n",
                            "    }\n",
                            "\n",
                            "    .dataframe tbody tr th {\n",
                            "        vertical-align: top;\n",
                            "    }\n",
                            "\n",
                            "    .dataframe thead th {\n",
                            "        text-align: right;\n",
                            "    }\n",
                            "</style>\n",
                            "<table border=\"1\" class=\"dataframe\">\n",
                            "  <thead>\n",
                            "    <tr style=\"text-align: right;\">\n",
                            "      <th>emotion</th>\n",
                            "      <th>word</th>\n",
                            "      <th>anger</th>\n",
                            "      <th>anticipation</th>\n",
                            "      <th>disgust</th>\n",
                            "      <th>fear</th>\n",
                            "      <th>joy</th>\n",
                            "      <th>negative</th>\n",
                            "      <th>positive</th>\n",
                            "      <th>sadness</th>\n",
                            "      <th>surprise</th>\n",
                            "      <th>trust</th>\n",
                            "    </tr>\n",
                            "  </thead>\n",
                            "  <tbody>\n",
                            "    <tr>\n",
                            "      <th>3</th>\n",
                            "      <td>abandoned</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>4</th>\n",
                            "      <td>abandonment</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>17</th>\n",
                            "      <td>abhor</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>18</th>\n",
                            "      <td>abhorrent</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>27</th>\n",
                            "      <td>abolish</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "  </tbody>\n",
                            "</table>\n",
                            "</div>"
                        ],
                        "text/plain": [
                            "emotion         word  anger  anticipation  disgust  fear  joy  negative  \\\n",
                            "3          abandoned      1             0        0     1    0         1   \n",
                            "4        abandonment      1             0        0     1    0         1   \n",
                            "17             abhor      1             0        1     1    0         1   \n",
                            "18         abhorrent      1             0        1     1    0         1   \n",
                            "27           abolish      1             0        0     0    0         1   \n",
                            "\n",
                            "emotion  positive  sadness  surprise  trust  \n",
                            "3               0        1         0      0  \n",
                            "4               0        1         1      0  \n",
                            "17              0        0         0      0  \n",
                            "18              0        0         0      0  \n",
                            "27              0        0         0      0  "
                        ]
                    },
                    "execution_count": 33,
                    "metadata": {},
                    "output_type": "execute_result"
                }
            ],
            "source": [
                "emolex_words[emolex_words.anger == 1].head()"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "...or multiple emotions!"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 34,
            "metadata": {},
            "outputs": [
                {
                    "data": {
                        "text/html": [
                            "<div>\n",
                            "<style scoped>\n",
                            "    .dataframe tbody tr th:only-of-type {\n",
                            "        vertical-align: middle;\n",
                            "    }\n",
                            "\n",
                            "    .dataframe tbody tr th {\n",
                            "        vertical-align: top;\n",
                            "    }\n",
                            "\n",
                            "    .dataframe thead th {\n",
                            "        text-align: right;\n",
                            "    }\n",
                            "</style>\n",
                            "<table border=\"1\" class=\"dataframe\">\n",
                            "  <thead>\n",
                            "    <tr style=\"text-align: right;\">\n",
                            "      <th>emotion</th>\n",
                            "      <th>word</th>\n",
                            "      <th>anger</th>\n",
                            "      <th>anticipation</th>\n",
                            "      <th>disgust</th>\n",
                            "      <th>fear</th>\n",
                            "      <th>joy</th>\n",
                            "      <th>negative</th>\n",
                            "      <th>positive</th>\n",
                            "      <th>sadness</th>\n",
                            "      <th>surprise</th>\n",
                            "      <th>trust</th>\n",
                            "    </tr>\n",
                            "  </thead>\n",
                            "  <tbody>\n",
                            "    <tr>\n",
                            "      <th>61</th>\n",
                            "      <td>abundance</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>1018</th>\n",
                            "      <td>balm</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>1382</th>\n",
                            "      <td>boisterous</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>1916</th>\n",
                            "      <td>celebrity</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "    </tr>\n",
                            "    <tr>\n",
                            "      <th>2004</th>\n",
                            "      <td>charmed</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "      <td>1</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "      <td>0</td>\n",
                            "    </tr>\n",
                            "  </tbody>\n",
                            "</table>\n",
                            "</div>"
                        ],
                        "text/plain": [
                            "emotion        word  anger  anticipation  disgust  fear  joy  negative  \\\n",
                            "61        abundance      0             1        1     0    1         1   \n",
                            "1018           balm      0             1        0     0    1         1   \n",
                            "1382     boisterous      1             1        0     0    1         1   \n",
                            "1916      celebrity      1             1        1     0    1         1   \n",
                            "2004        charmed      0             0        0     0    1         1   \n",
                            "\n",
                            "emotion  positive  sadness  surprise  trust  \n",
                            "61              1        0         0      1  \n",
                            "1018            1        0         0      0  \n",
                            "1382            1        0         0      0  \n",
                            "1916            1        0         1      1  \n",
                            "2004            1        0         0      0  "
                        ]
                    },
                    "execution_count": 34,
                    "metadata": {},
                    "output_type": "execute_result"
                }
            ],
            "source": [
                "emolex_words[(emolex_words.joy == 1) & (emolex_words.negative == 1)].head()"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "The useful part is going to be just getting words for a **single emotion.**"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 35,
            "metadata": {},
            "outputs": [
                {
                    "data": {
                        "text/plain": [
                            "3          abandoned\n",
                            "4        abandonment\n",
                            "17             abhor\n",
                            "18         abhorrent\n",
                            "27           abolish\n",
                            "            ...     \n",
                            "14122       wrongful\n",
                            "14123        wrongly\n",
                            "14147           yell\n",
                            "14150           yelp\n",
                            "14164          youth\n",
                            "Name: word, Length: 1247, dtype: object"
                        ]
                    },
                    "execution_count": 35,
                    "metadata": {},
                    "output_type": "execute_result"
                }
            ],
            "source": [
                "# Angry words\n",
                "emolex_words[emolex_words.anger == 1].word"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "## Review\n",
                "\n",
                "We took a quick look at the **Emotional Lexicon**, a sentiment analysis library that includes multiple emotional axes instead of just \"positive\" and \"negative.\""
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "## Discussion topics\n",
                "\n",
                "The Emotional Lexicon used words tagged individually by internet users. Do you think this is an effective method for understanding sentiment?\n",
                "\n",
                "How does this method compare to the [Sentiment140](http://www.sentiment140.com/) method that we covered in sentiment analysis?"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": []
        }
    ],
    "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.6.8"
        },
        "toc": {
            "base_numbering": 1,
            "nav_menu": {},
            "number_sections": true,
            "sideBar": true,
            "skip_h1_title": false,
            "title_cell": "Table of Contents",
            "title_sidebar": "Contents",
            "toc_cell": false,
            "toc_position": {},
            "toc_section_display": true,
            "toc_window_display": false
        }
    },
    "nbformat": 4,
    "nbformat_minor": 2
}