201 lines
4.8 KiB
Plaintext
201 lines
4.8 KiB
Plaintext
{
|
|
"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\n",
|
|
"import matplotlib\n"
|
|
]
|
|
},
|
|
{
|
|
"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": [
|
|
"matplotlib.rc('font', family='symbola', size=16)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"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",
|
|
" fig_1, ax_1 = plt.subplots(figsize=(15,10))\n",
|
|
" plt.title(title + \" -- sentiment-plot\")\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.savefig(title + \" -- sentiment-plot.png\", bbox_inches='tight')\n",
|
|
" \n",
|
|
" # sentiment score axis\n",
|
|
" X = np.array([x[0] for x in sentiment_vectors])\n",
|
|
" \n",
|
|
" # neutral axis:\n",
|
|
" Y = np.array([x[1] for x in sentiment_vectors])\n",
|
|
" \n",
|
|
" fig_2, ax_2 = plt.subplots(figsize=(15,10))\n",
|
|
" plt.title(title + \" -- positive-negative-plot\")\n",
|
|
" plt.xlabel(\"positive\")\n",
|
|
" plt.ylabel(\"negative\")\n",
|
|
" for i in range(len(X)):\n",
|
|
" plt.text(X[i], Y[i], unicode_repr[i])\n",
|
|
" plt.savefig(title + \" -- positive-negative-plot.png\", bbox_inches='tight')\n",
|
|
" #plt.show()\n",
|
|
" "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 7,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"application/vnd.jupyter.widget-view+json": {
|
|
"model_id": "130af70105914e61a07d14248df3d114",
|
|
"version_major": 2,
|
|
"version_minor": 0
|
|
},
|
|
"text/plain": [
|
|
"FigureCanvasNbAgg()"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
},
|
|
{
|
|
"data": {
|
|
"application/vnd.jupyter.widget-view+json": {
|
|
"model_id": "e6a1d7210b874215bb8d0e576b4ca133",
|
|
"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": 8,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"application/vnd.jupyter.widget-view+json": {
|
|
"model_id": "26d17ff521604443ab1da9ff63d1108a",
|
|
"version_major": 2,
|
|
"version_minor": 0
|
|
},
|
|
"text/plain": [
|
|
"FigureCanvasNbAgg()"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
},
|
|
{
|
|
"data": {
|
|
"application/vnd.jupyter.widget-view+json": {
|
|
"model_id": "188c871e705040c1b17bca0e10d5c5fe",
|
|
"version_major": 2,
|
|
"version_minor": 0
|
|
},
|
|
"text/plain": [
|
|
"FigureCanvasNbAgg()"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"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
|
|
}
|