{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%matplotlib widget" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "def sentiment_score(s):\n", " #(pos, neg, neu)^T\n", " return s[0] - s[1]" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import Emoji_Distance as edist\n", "import numpy as np\n", "from __future__ import unicode_literals\n", "\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "list_emoticon_scores = np.array([sentiment_score(x) for x in edist.list_sentiment_emoticon_vectors])" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "def plot_emoji_list(sentiment_vectors, unicode_repr, title=\"Emoji Space\"):\n", " \n", " # sentiment score axis\n", " X = np.array([sentiment_score(x) for x in sentiment_vectors])\n", " \n", " # neutral axis:\n", " Y = np.array([x[2] for x in sentiment_vectors])\n", " \n", " plt.title(title)\n", " plt.xlabel(\"sentiment score\")\n", " plt.ylabel(\"neutrality\")\n", " plt.xlim([-1,1])\n", " for i in range(len(X)):\n", " plt.text(X[i], Y[i], unicode_repr[i])\n", " plt.show()\n", " " ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "192190b95ac94d5bb04a5f2b73c7e481", "version_major": 2, "version_minor": 0 }, "text/plain": [ "FigureCanvasNbAgg()" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plot_emoji_list(sentiment_vectors=edist.list_sentiment_emoticon_vectors, unicode_repr=edist.list_emoticon_emojis, title=\"Emoticon Emoji space\")" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "plot_emoji_list(sentiment_vectors=edist.list_sentiment_vectors, unicode_repr=edist.list_emojis, title=\"Full Emoji space\")" ] }, { "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.5" } }, "nbformat": 4, "nbformat_minor": 2 }