nlp-lab/Project/Tools/emoji_plotting.ipynb

170 lines
151 KiB
Plaintext
Raw Normal View History

2018-07-16 11:54:56 +02:00
{
"cells": [
{
"cell_type": "code",
2018-07-16 12:10:35 +02:00
"execution_count": 1,
2018-07-16 11:54:56 +02:00
"metadata": {},
"outputs": [],
"source": [
2018-07-16 12:10:35 +02:00
"%matplotlib widget"
2018-07-16 11:54:56 +02:00
]
},
{
"cell_type": "code",
2018-07-16 12:10:35 +02:00
"execution_count": 2,
2018-07-16 11:54:56 +02:00
"metadata": {},
"outputs": [],
"source": [
"def sentiment_score(s):\n",
" #(pos, neg, neu)^T\n",
" return s[0] - s[1]"
]
},
{
"cell_type": "code",
2018-07-16 12:10:35 +02:00
"execution_count": 3,
2018-07-16 11:54:56 +02:00
"metadata": {},
"outputs": [],
"source": [
"import Emoji_Distance as edist\n",
2018-07-16 12:10:35 +02:00
"import numpy as np\n",
"from __future__ import unicode_literals\n",
"\n",
"import matplotlib.pyplot as plt"
2018-07-16 11:54:56 +02:00
]
},
{
"cell_type": "code",
2018-07-16 12:10:35 +02:00
"execution_count": 4,
2018-07-16 11:54:56 +02:00
"metadata": {},
"outputs": [],
"source": [
"list_emoticon_scores = np.array([sentiment_score(x) for x in edist.list_sentiment_emoticon_vectors])"
]
},
{
"cell_type": "code",
2018-07-16 12:11:39 +02:00
"execution_count": 14,
2018-07-16 11:54:56 +02:00
"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",
2018-07-16 12:11:39 +02:00
" fig_1, ax_1 = plt.subplots()\n",
2018-07-16 11:54:56 +02:00
" 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",
2018-07-16 12:11:39 +02:00
" #plt.show()\n",
" return fig_1"
2018-07-16 11:54:56 +02:00
]
},
{
"cell_type": "code",
2018-07-16 12:11:39 +02:00
"execution_count": 15,
2018-07-16 11:54:56 +02:00
"metadata": {},
"outputs": [
{
"data": {
2018-07-16 12:10:35 +02:00
"application/vnd.jupyter.widget-view+json": {
2018-07-16 12:11:39 +02:00
"model_id": "1ef9841e1ef94fdd8606e244eec54164",
2018-07-16 12:10:35 +02:00
"version_major": 2,
"version_minor": 0
},
2018-07-16 11:54:56 +02:00
"text/plain": [
2018-07-16 12:10:35 +02:00
"FigureCanvasNbAgg()"
2018-07-16 11:54:56 +02:00
]
},
"metadata": {},
"output_type": "display_data"
2018-07-16 12:11:39 +02:00
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkYAAAHFCAYAAAAXETaHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAPYQAAD2EBqD+naQAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzs3XlYjen/B/B3nbTQjlYqIllKKZRlLJFJIcvYs42ZwSzImuVChpDBb6xjbNPYmrEVxUyyTKbGTMgyyk5MC0mbUanu3x9O5+tMZcnpHPJ+Xde5xrmf7fOcjPPuee77ftSEEAJEREREBHVVF0BERET0tmAwIiIiIpJiMCIiIiKSYjAiIiIikmIwIiIiIpJiMCIiIiKSYjAiIiIikmIwIiIiIpJiMCIiIiKSYjAiUoJt27ZBTU2twteJEyeUXlNkZCTmz59f7jIbGxuMGjVKqfW8qtu3b7/ws6zonKrSiRMnyvwc58+fDzU1NaXXQkRvRkPVBRC9T7Zu3Qp7e/sy7c2aNVN6LZGRkVi7dm25QWL//v3Q19dXek2v48svv8TQoUPLtNerV0/ptbRq1QpxcXFyP8exY8fiww8/VHotRPRmGIyIlKhFix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N9D540ag0AOL777+XrQtAfP7553Lbl47ECg4OlmsvHQ31888/y7Vv2rRJODo6Ck1NTWFgYCD69Okj/v77b7l1CgoKxNixY0XdunWFmpqaACBu3bolhCg7Kk2IZyPeJk6cKKysrESNGjWEiYmJ8Pb
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
2018-07-16 11:54:56 +02:00
}
],
"source": [
"plot_emoji_list(sentiment_vectors=edist.list_sentiment_emoticon_vectors, unicode_repr=edist.list_emoticon_emojis, title=\"Emoticon Emoji space\")"
]
},
{
"cell_type": "code",
2018-07-16 12:11:39 +02:00
"execution_count": 16,
2018-07-16 11:54:56 +02:00
"metadata": {},
2018-07-16 12:11:39 +02:00
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7a14835ea00d4401b0fd2d6b7b65957f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FigureCanvasNbAgg()"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkYAAAHFCAYAAAAXETaHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAPYQAAD2EBqD+naQAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzs3XdYlfX7wPH3YU9FRVDAAVhCORNXDlRyZZqmlWmucluu6puU5khD81tZudMkU9NSEyeGlmSKAwG35kJBAYVk73Oe3x9+eX6eAAUFDuD9uq7nus7zedb9HBLuPlOjKIqCEEIIIYTAyNABCCGEEEKUF5IYCSGEEEL8jyRGQgghhBD/I4mREEIIIcT/SGIkhBBCCPE/khgJIYQQQvyPJEZCCCGEEP8jiZEQQgghxP9IYiSEEEII8T+SGAlRSfj7+6PRaArc3n///Ue+X2RkpFo2fPhw6tev/9Brhw8fXmgsGo2m2LGUhE6dOtGpU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vUIlRo/C19dXrzNmUlISdevWJSoqiipVqhgwMiFEaQgKCmLAgAFFOlej0dCxY0fWrFmjrp0mhCifkpOTqVOnDra2tqX6nAqVGNWqVYu4uDi9sri4OExMTApdBsDc3LzANZmqVKkiiZEQlZC1tXWRz1UUheDgYH744QdmzZpVekEJIUpMaXeDqVCJUdu2bdmxY4de2W+//YaXl1eB/YuEEE8eGxubIp9rbm5OZmZmKUYjhKhoDJoYpaamcvnyZXX/2rVrREREUL16derWrYuvry8
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
2018-07-16 11:54:56 +02:00
"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
}