From d556e45e74a96ddb6b4eeb5b972e82b6797ab331 Mon Sep 17 00:00:00 2001 From: Carsten Date: Sun, 10 Jun 2018 15:01:19 +0200 Subject: [PATCH 1/2] bipolar matching --- Project/naive_approach/Emoji_Distance.ipynb | 1330 +++---------------- 1 file changed, 153 insertions(+), 1177 deletions(-) diff --git a/Project/naive_approach/Emoji_Distance.ipynb b/Project/naive_approach/Emoji_Distance.ipynb index e1bb031..5b2fc06 100644 --- a/Project/naive_approach/Emoji_Distance.ipynb +++ b/Project/naive_approach/Emoji_Distance.ipynb @@ -4,6 +4,11 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Emoji Distance\n", + "a notebook dealing witch emoji distance measures. Uses an external csv with labeled data to compare arbitriary emojis related to sentiment\n", + "Autor = Carsten Draschner\n", + "Version = 0.1\n", + "## Used Ressources\n", "https://www.clarin.si/repository/xmlui/handle/11356/1048\n", "https://github.com/words/emoji-emotion" ] @@ -24,1216 +29,187 @@ { "cell_type": "code", "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
EmojiUnicode codepointOccurrencesPositionNegativeNeutralPositiveUnicode nameUnicode block
0😂0x1f602146220.805101361441636845FACE WITH TEARS OF JOYEmoticons
10x276480500.74694335513346361HEAVY BLACK HEARTDingbats
20x266571440.75380625219424950BLACK HEART SUITMiscellaneous Symbols
3😍0x1f60d63590.76529232913904640SMILING FACE WITH HEART-SHAPED EYESEmoticons
4😭0x1f62d55260.803352241212181896LOUDLY CRYING FACEEmoticons
5😘0x1f61836480.8544801937022753FACE THROWING A KISSEmoticons
6😊0x1f60a31860.8133021897542243SMILING FACE WITH SMILING EYESEmoticons
7👌0x1f44c29250.8052232747281923OK HAND SIGNMiscellaneous Symbols and Pictographs
8💕0x1f49524000.765726996831618TWO HEARTSMiscellaneous Symbols and Pictographs
9👏0x1f44f23360.7871302436341459CLAPPING HANDS SIGNMiscellaneous Symbols and Pictographs
10😁0x1f60121890.7961512786481263GRINNING FACE WITH SMILING EYESEmoticons
110x263a20620.7986341284491485WHITE SMILING FACEMiscellaneous Symbols
120x266119750.7636951024481425WHITE HEART SUITMiscellaneous Symbols
13👍0x1f44d18540.8121262134601181THUMBS UP SIGNMiscellaneous Symbols and Pictographs
14😩0x1f62918080.8262141069336403WEARY FACEEmoticons
15🙏0x1f64f15390.793848124648767PERSON WITH FOLDED HANDSEmoticons
160x270c15340.790480173476885VICTORY HANDDingbats
17😏0x1f60f15220.764977170676676SMIRKING FACEEmoticons
18😉0x1f60915210.844833151513857WINKING FACEEmoticons
19🙌0x1f64c15060.790600152358996PERSON RAISING BOTH HANDS IN CELEBRATIONEmoticons
20🙈0x1f64814560.738881238350868SEE-NO-EVIL MONKEYEmoticons
21💪0x1f4aa14090.806704101424884FLEXED BICEPSMiscellaneous Symbols and Pictographs
22😄0x1f60413980.794973191426781SMILING FACE WITH OPEN MOUTH AND SMILING EYESEmoticons
23😒0x1f61213850.857621819266300UNAMUSED FACEEmoticons
24💃0x1f48313440.852765592371048DANCERMiscellaneous Symbols and Pictographs
25💖0x1f49612630.76223954254955SPARKLING HEARTMiscellaneous Symbols and Pictographs
26😃0x1f60312060.73478286361759SMILING FACE WITH OPEN MOUTHEmoticons
27😔0x1f61412050.866146559263383PENSIVE FACEEmoticons
28😱0x1f63111300.773313298319513FACE SCREAMING IN FEAREmoticons
29🎉0x1f38911250.74363643207875PARTY POPPERMiscellaneous Symbols and Pictographs
..............................
939🕥0x1f56510.811966100CLOCK FACE TEN-THIRTYMiscellaneous Symbols and Pictographs
9400x265910.342857010WHITE CHESS PAWNMiscellaneous Symbols
9410x25bf10.432836010WHITE DOWN-POINTING SMALL TRIANGLEGeometric Shapes
9420x268310.918919010DIE FACE-4Miscellaneous Symbols
9430x273d10.992701001HEAVY TEARDROP-SPOKED ASTERISKDingbats
944📼0x1f4fc11.000000001VIDEOCASSETTEMiscellaneous Symbols and Pictographs
945🕐0x1f55011.000000100CLOCK FACE ONE OCLOCKMiscellaneous Symbols and Pictographs
946🀄0x1f00411.000000001MAHJONG TILE RED DRAGONMahjong Tiles
9470x273e10.023256010SIX PETALLED BLACK AND WHITE FLORETTEDingbats
9480x272c10.955224001BLACK CENTRE WHITE STARDingbats
949🆑0x1f19110.983607010SQUARED CLEnclosed Alphanumeric Supplement
9500x272b10.923729001OPEN CENTRE BLACK STARDingbats
951🕔0x1f55410.742424100CLOCK FACE FIVE OCLOCKMiscellaneous Symbols and Pictographs
9520x276310.471429001HEAVY HEART EXCLAMATION MARK ORNAMENTDingbats
9530x27b110.704348010NOTCHED UPPER RIGHT-SHADOWED WHITE RIGHTWARDS ...Dingbats
954🆕0x1f19510.669118010SQUARED NEWEnclosed Alphanumeric Supplement
9550x27a210.242647010THREE-D TOP-LIGHTED RIGHTWARDS ARROWHEADDingbats
9560x219510.735632010UP DOWN ARROWArrows
957📫0x1f4eb10.384615001CLOSED MAILBOX WITH RAISED FLAGMiscellaneous Symbols and Pictographs
958🉐0x1f25010.031250001CIRCLED IDEOGRAPH ADVANTAGEEnclosed Ideographic Supplement
9590x264a10.327586010GEMINIMiscellaneous Symbols
960🈂0x1f20210.466667100SQUARED KATAKANA SAEnclosed Ideographic Supplement
961🎰0x1f3b010.421687100SLOT MACHINEMiscellaneous Symbols and Pictographs
962҂0x48210.519231100CYRILLIC THOUSANDS SIGNCyrillic
9630x256410.634615100BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLEBox Drawing
9640x279b10.011628010DRAFTING POINT RIGHTWARDS ARROWDingbats
9650x265d10.280000010BLACK CHESS BISHOPMiscellaneous Symbols
9660x274b10.888889010HEAVY EIGHT TEARDROP-SPOKED PROPELLER ASTERISKDingbats
9670x270610.557252010TELEPHONE LOCATION SIGNDingbats
968📔0x1f4d410.814815001NOTEBOOK WITH DECORATIVE COVERMiscellaneous Symbols and Pictographs
\n", - "

969 rows × 9 columns

\n", - "
" - ], - "text/plain": [ - " Emoji Unicode codepoint Occurrences Position Negative Neutral \\\n", - "0 😂 0x1f602 14622 0.805101 3614 4163 \n", - "1 ❤ 0x2764 8050 0.746943 355 1334 \n", - "2 ♥ 0x2665 7144 0.753806 252 1942 \n", - "3 😍 0x1f60d 6359 0.765292 329 1390 \n", - "4 😭 0x1f62d 5526 0.803352 2412 1218 \n", - "5 😘 0x1f618 3648 0.854480 193 702 \n", - "6 😊 0x1f60a 3186 0.813302 189 754 \n", - "7 👌 0x1f44c 2925 0.805223 274 728 \n", - "8 💕 0x1f495 2400 0.765726 99 683 \n", - "9 👏 0x1f44f 2336 0.787130 243 634 \n", - "10 😁 0x1f601 2189 0.796151 278 648 \n", - "11 ☺ 0x263a 2062 0.798634 128 449 \n", - "12 ♡ 0x2661 1975 0.763695 102 448 \n", - "13 👍 0x1f44d 1854 0.812126 213 460 \n", - "14 😩 0x1f629 1808 0.826214 1069 336 \n", - "15 🙏 0x1f64f 1539 0.793848 124 648 \n", - "16 ✌ 0x270c 1534 0.790480 173 476 \n", - "17 😏 0x1f60f 1522 0.764977 170 676 \n", - "18 😉 0x1f609 1521 0.844833 151 513 \n", - "19 🙌 0x1f64c 1506 0.790600 152 358 \n", - "20 🙈 0x1f648 1456 0.738881 238 350 \n", - "21 💪 0x1f4aa 1409 0.806704 101 424 \n", - "22 😄 0x1f604 1398 0.794973 191 426 \n", - "23 😒 0x1f612 1385 0.857621 819 266 \n", - "24 💃 0x1f483 1344 0.852765 59 237 \n", - "25 💖 0x1f496 1263 0.762239 54 254 \n", - "26 😃 0x1f603 1206 0.734782 86 361 \n", - "27 😔 0x1f614 1205 0.866146 559 263 \n", - "28 😱 0x1f631 1130 0.773313 298 319 \n", - "29 🎉 0x1f389 1125 0.743636 43 207 \n", - ".. ... ... ... ... ... ... \n", - "939 🕥 0x1f565 1 0.811966 1 0 \n", - "940 ♙ 0x2659 1 0.342857 0 1 \n", - "941 ▿ 0x25bf 1 0.432836 0 1 \n", - "942 ⚃ 0x2683 1 0.918919 0 1 \n", - "943 ✽ 0x273d 1 0.992701 0 0 \n", - "944 📼 0x1f4fc 1 1.000000 0 0 \n", - "945 🕐 0x1f550 1 1.000000 1 0 \n", - "946 🀄 0x1f004 1 1.000000 0 0 \n", - "947 ✾ 0x273e 1 0.023256 0 1 \n", - "948 ✬ 0x272c 1 0.955224 0 0 \n", - "949 🆑 0x1f191 1 0.983607 0 1 \n", - "950 ✫ 0x272b 1 0.923729 0 0 \n", - "951 🕔 0x1f554 1 0.742424 1 0 \n", - "952 ❣ 0x2763 1 0.471429 0 0 \n", - "953 ➱ 0x27b1 1 0.704348 0 1 \n", - "954 🆕 0x1f195 1 0.669118 0 1 \n", - "955 ➢ 0x27a2 1 0.242647 0 1 \n", - "956 ↕ 0x2195 1 0.735632 0 1 \n", - "957 📫 0x1f4eb 1 0.384615 0 0 \n", - "958 🉐 0x1f250 1 0.031250 0 0 \n", - "959 ♊ 0x264a 1 0.327586 0 1 \n", - "960 🈂 0x1f202 1 0.466667 1 0 \n", - "961 🎰 0x1f3b0 1 0.421687 1 0 \n", - "962 ҂ 0x482 1 0.519231 1 0 \n", - "963 ╤ 0x2564 1 0.634615 1 0 \n", - "964 ➛ 0x279b 1 0.011628 0 1 \n", - "965 ♝ 0x265d 1 0.280000 0 1 \n", - "966 ❋ 0x274b 1 0.888889 0 1 \n", - "967 ✆ 0x2706 1 0.557252 0 1 \n", - "968 📔 0x1f4d4 1 0.814815 0 0 \n", - "\n", - " Positive Unicode name \\\n", - "0 6845 FACE WITH TEARS OF JOY \n", - "1 6361 HEAVY BLACK HEART \n", - "2 4950 BLACK HEART SUIT \n", - "3 4640 SMILING FACE WITH HEART-SHAPED EYES \n", - "4 1896 LOUDLY CRYING FACE \n", - "5 2753 FACE THROWING A KISS \n", - "6 2243 SMILING FACE WITH SMILING EYES \n", - "7 1923 OK HAND SIGN \n", - "8 1618 TWO HEARTS \n", - "9 1459 CLAPPING HANDS SIGN \n", - "10 1263 GRINNING FACE WITH SMILING EYES \n", - "11 1485 WHITE SMILING FACE \n", - "12 1425 WHITE HEART SUIT \n", - "13 1181 THUMBS UP SIGN \n", - "14 403 WEARY FACE \n", - "15 767 PERSON WITH FOLDED HANDS \n", - "16 885 VICTORY HAND \n", - "17 676 SMIRKING FACE \n", - "18 857 WINKING FACE \n", - "19 996 PERSON RAISING BOTH HANDS IN CELEBRATION \n", - "20 868 SEE-NO-EVIL MONKEY \n", - "21 884 FLEXED BICEPS \n", - "22 781 SMILING FACE WITH OPEN MOUTH AND SMILING EYES \n", - "23 300 UNAMUSED FACE \n", - "24 1048 DANCER \n", - "25 955 SPARKLING HEART \n", - "26 759 SMILING FACE WITH OPEN MOUTH \n", - "27 383 PENSIVE FACE \n", - "28 513 FACE SCREAMING IN FEAR \n", - "29 875 PARTY POPPER \n", - ".. ... ... \n", - "939 0 CLOCK FACE TEN-THIRTY \n", - "940 0 WHITE CHESS PAWN \n", - "941 0 WHITE DOWN-POINTING SMALL TRIANGLE \n", - "942 0 DIE FACE-4 \n", - "943 1 HEAVY TEARDROP-SPOKED ASTERISK \n", - "944 1 VIDEOCASSETTE \n", - "945 0 CLOCK FACE ONE OCLOCK \n", - "946 1 MAHJONG TILE RED DRAGON \n", - "947 0 SIX PETALLED BLACK AND WHITE FLORETTE \n", - "948 1 BLACK CENTRE WHITE STAR \n", - "949 0 SQUARED CL \n", - "950 1 OPEN CENTRE BLACK STAR \n", - "951 0 CLOCK FACE FIVE OCLOCK \n", - "952 1 HEAVY HEART EXCLAMATION MARK ORNAMENT \n", - "953 0 NOTCHED UPPER RIGHT-SHADOWED WHITE RIGHTWARDS ... \n", - "954 0 SQUARED NEW \n", - "955 0 THREE-D TOP-LIGHTED RIGHTWARDS ARROWHEAD \n", - "956 0 UP DOWN ARROW \n", - "957 1 CLOSED MAILBOX WITH RAISED FLAG \n", - "958 1 CIRCLED IDEOGRAPH ADVANTAGE \n", - "959 0 GEMINI \n", - "960 0 SQUARED KATAKANA SA \n", - "961 0 SLOT MACHINE \n", - "962 0 CYRILLIC THOUSANDS SIGN \n", - "963 0 BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE \n", - "964 0 DRAFTING POINT RIGHTWARDS ARROW \n", - "965 0 BLACK CHESS BISHOP \n", - "966 0 HEAVY EIGHT TEARDROP-SPOKED PROPELLER ASTERISK \n", - "967 0 TELEPHONE LOCATION SIGN \n", - "968 1 NOTEBOOK WITH DECORATIVE COVER \n", - "\n", - " Unicode block \n", - "0 Emoticons \n", - "1 Dingbats \n", - "2 Miscellaneous Symbols \n", - "3 Emoticons \n", - "4 Emoticons \n", - "5 Emoticons \n", - "6 Emoticons \n", - "7 Miscellaneous Symbols and Pictographs \n", - "8 Miscellaneous Symbols and Pictographs \n", - "9 Miscellaneous Symbols and Pictographs \n", - "10 Emoticons \n", - "11 Miscellaneous Symbols \n", - "12 Miscellaneous Symbols \n", - "13 Miscellaneous Symbols and Pictographs \n", - "14 Emoticons \n", - "15 Emoticons \n", - "16 Dingbats \n", - "17 Emoticons \n", - "18 Emoticons \n", - "19 Emoticons \n", - "20 Emoticons \n", - "21 Miscellaneous Symbols and Pictographs \n", - "22 Emoticons \n", - "23 Emoticons \n", - "24 Miscellaneous Symbols and Pictographs \n", - "25 Miscellaneous Symbols and Pictographs \n", - "26 Emoticons \n", - "27 Emoticons \n", - "28 Emoticons \n", - "29 Miscellaneous Symbols and Pictographs \n", - ".. ... \n", - "939 Miscellaneous Symbols and Pictographs \n", - "940 Miscellaneous Symbols \n", - "941 Geometric Shapes \n", - "942 Miscellaneous Symbols \n", - "943 Dingbats \n", - "944 Miscellaneous Symbols and Pictographs \n", - "945 Miscellaneous Symbols and Pictographs \n", - "946 Mahjong Tiles \n", - "947 Dingbats \n", - "948 Dingbats \n", - "949 Enclosed Alphanumeric Supplement \n", - "950 Dingbats \n", - "951 Miscellaneous Symbols and Pictographs \n", - "952 Dingbats \n", - "953 Dingbats \n", - "954 Enclosed Alphanumeric Supplement \n", - "955 Dingbats \n", - "956 Arrows \n", - "957 Miscellaneous Symbols and Pictographs \n", - "958 Enclosed Ideographic Supplement \n", - "959 Miscellaneous Symbols \n", - "960 Enclosed Ideographic Supplement \n", - "961 Miscellaneous Symbols and Pictographs \n", - "962 Cyrillic \n", - "963 Box Drawing \n", - "964 Dingbats \n", - "965 Miscellaneous Symbols \n", - "966 Dingbats \n", - "967 Dingbats \n", - "968 Miscellaneous Symbols and Pictographs \n", - "\n", - "[969 rows x 9 columns]" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df = pd.read_csv(\"/Users/Carsten/GitRepos/NLP-LAB/Project/Tools/Emoji_Sentiment_Data_v1.0.csv\", delimiter=\";\")\n", - "df#.head()" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "df_filtered = df[df[\"Unicode block\"]==\"Emoticons\"]" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array(['😂', '😍', '😭', '😘', '😊', '😁', '😩', '🙏', '😏', '😉', '🙌', '🙈', '😄',\n", - " '😒', '😃', '😔', '😱', '😜', '😳', '😡', '😎', '😢', '😋', '🙊', '😴', '😌',\n", - " '😞', '😆', '😝', '😪', '😫', '😅', '😀', '😚', '😻', '😥', '😕', '😤', '😈',\n", - " '😰', '😑', '😹', '😠', '😓', '😣', '😐', '😨', '😖', '😷', '🙋', '😛', '😬',\n", - " '😙', '🙆', '🙅', '🙉', '😇', '😿', '😲', '😶', '😵', '😸', '😧', '😮', '😽',\n", - " '🙀', '🙇', '😟', '😯', '😦', '🙍', '😺', '😾', '😼', '🙎', '😗'], dtype=object)" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df_filtered['Emoji'].values" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "def sentiment_vector_dist(v1,v2):\n", - " pos_v1 = v1[0]\n", - " neg_v1 = v1[1]\n", - " neu_v1 = v1[2]\n", - " \n", - " pos_v2 = v2[0]\n", - " neg_v2 = v2[1]\n", - " neu_v2 = v2[2]\n", - " \n", - " #tmp_dist = float(np.abs(pos_v1-pos_v2))+float(np.abs(neg_v1-neg_v2))+float(np.abs(neu_v1-neu_v2))\n", - "\n", - "\n", - " \n", - " tmp_dist = np.linalg.norm(np.array(v1)-np.array(v2))\n", - " \n", - " return tmp_dist\n", - " \n", - "#sentiment_vector_dist([0.2,.9,.01],[0.3,0.3,0.4])" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[ 0.46813021],\n", - " [ 0.24716181],\n", - " [ 0.28470797]])" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "def emoji_to_sentiment_vector(e):\n", - " tmp = df[df[\"Emoji\"]==e]\n", - " \n", - " #display(\"tmp\", tmp[\"Positive\"])\n", - " \n", - " pos = tmp[\"Positive\"].values/tmp[\"Occurrences\"].values\n", - " neg = tmp[\"Negative\"].values/tmp[\"Occurrences\"].values\n", - " neu = tmp[\"Neutral\"].values/tmp[\"Occurrences\"].values\n", - " \n", - " return np.array([pos,neg,neu])\n", - "\n", - "emoji_to_sentiment_vector(\"😂\")" - ] - }, - { - "cell_type": "code", - "execution_count": 7, "metadata": { "collapsed": true }, "outputs": [], "source": [ + "#read in csv as panda file\n", + "df = pd.read_csv(\"/Users/Carsten/GitRepos/NLP-LAB/Project/Tools/Emoji_Sentiment_Data_v1.0.csv\", delimiter=\";\")\n", + "#df.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "#calculates vector distance between 2 3-dim sentiment representations of emojis\n", + "def sentiment_vector_dist(v1,v2):\n", + " #pos_v1 = v1[0]\n", + " #neg_v1 = v1[1]\n", + " #neu_v1 = v1[2]\n", + " \n", + " #pos_v2 = v2[0]\n", + " #neg_v2 = v2[1]\n", + " #neu_v2 = v2[2]\n", + " \n", + " #tmp_dist = float(np.abs(pos_v1-pos_v2))+float(np.abs(neg_v1-neg_v2))+float(np.abs(neu_v1-neu_v2))\n", + " \n", + " #calculates vector distance between 2 3-dim sentiment representations of emojis consisting of positive neutral and negative probabilistic occuring\n", + " tmp_dist = np.linalg.norm(np.array(v1)-np.array(v2)) \n", + " return tmp_dist" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "#calculates vector representation in a 3dim 0 to 1space of dimension: positive,negative,neutral\n", + "def emoji_to_sentiment_vector(e):\n", + " tmp = df[df[\"Emoji\"]==e] \n", + " #calculate by espacial labeled occurences devided by sum of overall occurences\n", + " pos = tmp[\"Positive\"].values/tmp[\"Occurrences\"].values\n", + " neg = tmp[\"Negative\"].values/tmp[\"Occurrences\"].values\n", + " neu = tmp[\"Neutral\"].values/tmp[\"Occurrences\"].values\n", + " #return as np array\n", + " return np.array([pos,neg,neu])" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "#function to call for evaluating two emojis in its sentimental distance\n", "def emoji_distance(e1,e2):\n", " sent_v1 = emoji_to_sentiment_vector(e1)\n", " sent_v2 = emoji_to_sentiment_vector(e2)\n", - " #display(sent_v1, sent_v2)\n", + " \n", " d = sentiment_vector_dist(sent_v1,sent_v2)\n", " return d" ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 42, "metadata": {}, "outputs": [], "source": [ - "all_smilies = list(df_filtered[\"Emoji\"])\n", - "#all_smilies = list(df[\"Emoji\"])\n", - "\n", - "\n", - "d_m = np.zeros(shape=(len(all_smilies),len(all_smilies)))\n", - "#c1,c2 = 0\n", - "for c1 in range(len(all_smilies)):\n", - " for c2 in range(len(all_smilies)):\n", - " e1 = all_smilies[c1]\n", - " e2 = all_smilies[c2]\n", + "def sentiment_vector_to_emoji(v1):\n", + " #if(len(v1) == 3):\n", + " #set initial values to compare with\n", + " best_emoji = \"😐\"\n", + " min_distance = 10000\n", " \n", - " d = emoji_distance(e1,e2)\n", - " d_m[c1,c2] = d\n", - " \n", - " #print(e1,e2,d)\n", + " #compare only with filtred emoticons\n", + " df_filtered = df[df[\"Unicode block\"]==\"Emoticons\"]\n", + " all_smilies = list(df_filtered[\"Emoji\"])\n", + " for e in all_smilies:\n", + " v2 = emoji_to_sentiment_vector(e)\n", + " d = sentiment_vector_dist(v1,v2)\n", + " if(d < min_distance):\n", + " min_distance = d\n", + " best_emoji = e\n", + " print(str(v1),str(v2),str(min_distance),str(type(v1)),str(type(v2)),e)\n", "\n", - " \n" + "\n", + " print(\"for sentiment vector: \"+str(v1)+\" the emoji is : \"+str(best_emoji)+\" with distance of \"+str(min_distance)+\"!\")\n", + " return best_emoji\n", + " \n", + " #else:\n", + " #print(\"WRONG SENTIMENT VECTOR\")" ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 43, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def show_demo():\n", + " df_filtered = df[df[\"Unicode block\"]==\"Emoticons\"]\n", + " all_smilies = list(df_filtered[\"Emoji\"])\n", + "\n", + " d_m = np.zeros(shape=(len(all_smilies),len(all_smilies)))\n", + "\n", + " for c1 in range(len(all_smilies)):\n", + " for c2 in range(len(all_smilies)):\n", + " e1 = all_smilies[c1]\n", + " e2 = all_smilies[c2]\n", + "\n", + " d = emoji_distance(e1,e2)\n", + " d_m[c1,c2] = d\n", + " \n", + " for c in range(len(d_m[0])):\n", + " emoji = all_smilies[c]\n", + " row = d_m[c]\n", + " row_sorted = np.argsort(row)\n", + " #closest 5\n", + " r = row_sorted[0:10]\n", + " #print()\n", + " closest = \"\"\n", + " for i in r:\n", + " closest+=all_smilies[i]\n", + " print(emoji+\": \"+closest)" + ] + }, + { + "cell_type": "code", + "execution_count": 46, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "😂: 😂😱😬🙇😈😹😅😥🙉😵\n", - "😍: 😍😊😘😚😻😛😋😇🙌😀\n", - "😭: 😭😪😓😴😔😷😖😫😢😨\n", - "😘: 😘😚😍😙😊😗😛😻😽😋\n", - "😊: 😊😻😛😍😇😋😀🙌😘😚\n", - "😁: 😁😄😝😎🙊😜😆🙆😉🙋\n", - "😩: 😩😒😕🙍😿😾😠😦😐😑\n", - "🙏: 🙏😏😸😉🙀😮😜😝😄🙉\n", - "😏: 😏🙏😮🙀😸😈🙉😉😜😝\n", - "😉: 😉😜😸😝🙆😄😁😎😆🙊\n", - "🙌: 🙌😀😛😻😇🙋😌😊😋😃\n", - "🙈: 🙈😼😌🙊🙋😆😁😄😺😎\n", - "😄: 😄😝😁😆😜🙊😉😎😸🙉\n", - "😒: 😒😩😕😿🙍😾😠😦😐😑\n", - "😃: 😃🙆😎😀😇😋🙋🙌😁🙊\n", - "😔: 😔😷😭😖😪😓😴😫😤😨\n", - "😱: 😱😬😂🙇😹😅😥😵😈😯\n", - "😜: 😜😉😝😁😄🙆😎😸😆🙊\n", - "😳: 😳😲😧😵😯🙇😹😶😢😥\n", - "😡: 😡😣😞🙎😫😖😰😠😔😷\n", - "😎: 😎🙆😁🙊😜😃😄😝🙋😉\n", - "😢: 😢😟😪😓😴😭😵😥😧😰\n", - "😋: 😋😇😻😀😊😃😛🙌😍🙆\n", - "🙊: 🙊🙋😁😆😎🙈😌😄😼😝\n", - "😴: 😴😭😪😓😔😧😨😢😷😲\n", - "😌: 😌🙋🙈🙊🙌😼😀😎😆😁\n", - "😞: 😞😫😖🙎😰😓😔😡😪😭\n", - "😆: 😆😄😁🙊😝😼🙈😜😎🙉\n", - "😝: 😝😄😜😁😆😉😸😎🙊🙆\n", - "😪: 😪😓😭😴😔😢😷😖😫😞\n", - "😫: 😫😖😞😔😷😭😓😪😣😡\n", - "😅: 😅😹😥😬🙇😱😂😟😵😢\n", - "😀: 😀😇🙌😻😛😋😃🙋😊😌\n", - "😚: 😚😘😍😙😗😊😛😻😽😋\n", - "😻: 😻😊😛😇😀😋🙌😍😘😃\n", - "😥: 😥😹😟😅😵🙇😬😱😢😂\n", - "😕: 😕😒😩😿🙍😾😠😦😐😑\n", - "😤: 😤🙅😷😨😔😶😑😖😭😴\n", - "😈: 😈😮🙉🙀😂😱😬😯🙇😄\n", - "😰: 😰🙎😞😫😓😢😪😭😖😟\n", - "😑: 😑😦😐🙅😤😿😶😒😨😕\n", - "😹: 😹🙇😥😬😅😵😱😂😟😢\n", - "😠: 😠🙍😾😩😒😕😿😣😖😫\n", - "😓: 😓😪😭😴😔😢😷😖😫😞\n", - "😣: 😣😡😫😞😠😖🙍😾🙎😷\n", - "😐: 😐😦😑😿😕😒😩🙅😤🙍\n", - "😨: 😨😶🙅😤😧😲😴😔😷😭\n", - "😖: 😖😫😔😷😞😭😓😪😣😴\n", - "😷: 😷😔😖😤😭😫😪😓😨😴\n", - "🙋: 🙋😌🙊🙈😎🙌😀😁😆😼\n", - "😛: 😛😻😊🙌😀😇😍😋😘😽\n", - "😬: 😬😱😂🙇😹😅😥😵😈😟\n", - "😙: 😙😚😘😗😍😊😛😻😽😋\n", - "🙆: 🙆😎😜😃😉😁😝😄🙊😸\n", - "🙅: 🙅😤😶😨😑😷😔😲😧😴\n", - "🙉: 🙉🙀😈😄😝😆😸😮😁😜\n", - "😇: 😇😀😋😻🙌😊😛😃🙋😍\n", - "😿: 😿😒😕😩🙍😦😠😐😾😑\n", - "😲: 😲😧😶😨😴😳😭😪😓🙅\n", - "😶: 😶😨🙅😲😧😤😴😔😷😭\n", - "😵: 😵🙇😹😥😟😱😬😅😢😳\n", - "😸: 😸😉😜😝😄🙀😁🙉🙆😎\n", - "😧: 😧😲😨😴😶😭😪😳😓😢\n", - "😮: 😮😈🙀🙉😏😸😯😂🙏😱\n", - "😽: 😽😛😘😍😚🙌😊😻😗😺\n", - "🙀: 🙀🙉😮😈😸😝😄😜😉😆\n", - "🙇: 🙇😹😱😬😵😥😂😅😟😯\n", - "😟: 😟😥😢😵😹😅🙇😬😱😓\n", - "😯: 😯😳🙇😱😈😵😮😂😬😹\n", - "😦: 😦😐😑😿😕😒😩🙅😤🙍\n", - "🙍: 🙍😾😩😠😒😕😿😣😖😡\n", - "😺: 😺🙈😌😼🙋😽🙊🙌😆😛\n", - "😾: 😾🙍😩😠😒😕😿😣😡😖\n", - "😼: 😼🙈😆🙊😌😁🙋😄😝🙉\n", - "🙎: 🙎😰😞😡😫😖😣😓😪😭\n", - "😗: 😗😙😚😘😽😍😊😛😻🙌\n" + "[[ 0.39118825]\n", + " [ 0.38451268]\n", + " [ 0.22429907]] [[ 0.46813021]\n", + " [ 0.24716181]\n", + " [ 0.28470797]] 0.168625514858 😂\n", + "[[ 0.39118825]\n", + " [ 0.38451268]\n", + " [ 0.22429907]] [[ 0.34310532]\n", + " [ 0.43648208]\n", + " [ 0.2204126 ]] 0.0709076267317 😭\n", + "[[ 0.39118825]\n", + " [ 0.38451268]\n", + " [ 0.22429907]] [[ 0.39118825]\n", + " [ 0.38451268]\n", + " [ 0.22429907]] 0.0 😢\n", + "for sentiment vector: [[ 0.39118825]\n", + " [ 0.38451268]\n", + " [ 0.22429907]] the emoji is : 😢 with distance of 0.0!\n" ] + }, + { + "data": { + "text/plain": [ + "'😢'" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "for c in range(len(d_m[0])):\n", - " emoji = all_smilies[c]\n", - " row = d_m[c]\n", - " row_sorted = np.argsort(row)\n", - " #closest 5\n", - " r = row_sorted[0:10]\n", - " #print()\n", - " closest = \"\"\n", - " for i in r:\n", - " closest+=all_smilies[i]\n", - " print(emoji+\": \"+closest)\n", - " " + "#show_demo()\n", + "v11 = emoji_to_sentiment_vector(\"😢\")\n", + "sentiment_vector_to_emoji(v11)" ] }, { From 2cbb06ea949f15cdbb3903a5436d731b3bef3c4e Mon Sep 17 00:00:00 2001 From: Carsten Date: Sun, 10 Jun 2018 15:14:41 +0200 Subject: [PATCH 2/2] bipolar matching as .py --- Project/Tools/Emoji_Distance.py | 146 ++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 Project/Tools/Emoji_Distance.py diff --git a/Project/Tools/Emoji_Distance.py b/Project/Tools/Emoji_Distance.py new file mode 100644 index 0000000..6aebde8 --- /dev/null +++ b/Project/Tools/Emoji_Distance.py @@ -0,0 +1,146 @@ + +# coding: utf-8 + +# # Emoji Distance +# a notebook dealing witch emoji distance measures. Uses an external csv with labeled data to compare arbitriary emojis related to sentiment +# Autor = Carsten Draschner +# Version = 0.1 +# ## Used Ressources +# https://www.clarin.si/repository/xmlui/handle/11356/1048 +# https://github.com/words/emoji-emotion + +# In[1]: + + +import pandas as pd +import math +import numpy as np + +N=3 +# In[53]: + + +#read in csv as panda file +df = pd.read_csv("/Users/Carsten/GitRepos/NLP-LAB/Project/Tools/Emoji_Sentiment_Data_v1.0.csv", delimiter=";") +#df.head() + + +# In[54]: + + +#calculates vector distance between 2 3-dim sentiment representations of emojis +def sentiment_vector_dist(v1,v2): + #pos_v1 = v1[0] + #neg_v1 = v1[1] + #neu_v1 = v1[2] + + #pos_v2 = v2[0] + #neg_v2 = v2[1] + #neu_v2 = v2[2] + + #tmp_dist = float(np.abs(pos_v1-pos_v2))+float(np.abs(neg_v1-neg_v2))+float(np.abs(neu_v1-neu_v2)) + + #calculates vector distance between 2 3-dim sentiment representations of emojis consisting of positive neutral and negative probabilistic occuring + tmp_dist = np.linalg.norm(np.array(v1)-np.array(v2)) + return tmp_dist + + +# In[55]: + + +#calculates vector representation in a 3dim 0 to 1space of dimension: positive,negative,neutral +def emoji_to_sentiment_vector(e): + tmp = df[df["Emoji"]==e] + #calculate by espacial labeled occurences devided by sum of overall occurences + pos = tmp["Positive"].values[0]/tmp["Occurrences"].values[0] + neg = tmp["Negative"].values[0]/tmp["Occurrences"].values[0] + neu = tmp["Neutral"].values[0]/tmp["Occurrences"].values[0] + #return as np array + return np.array([pos,neg,neu]) + + +# In[56]: + + +#function to call for evaluating two emojis in its sentimental distance +def emoji_distance(e1,e2): + sent_v1 = emoji_to_sentiment_vector(e1) + sent_v2 = emoji_to_sentiment_vector(e2) + + d = sentiment_vector_dist(sent_v1,sent_v2) + return d + + +# In[57]: + + +def sentiment_vector_to_emoji(v1): + #if(len(v1) == 3): + #set initial values to compare with + best_emoji = "😐" + min_distance = 10000 + + #compare only with filtred emoticons + df_filtered = df[df["Unicode block"]=="Emoticons"] + all_smilies = list(df_filtered["Emoji"]) + for e in all_smilies: + v2 = emoji_to_sentiment_vector(e) + d = sentiment_vector_dist(v1,v2) + if(d < min_distance): + min_distance = d + best_emoji = e + #print(str(v1),str(v2),str(min_distance),str(type(v1)),str(type(v2)),e) + + + #print("for sentiment vector: "+str(v1)+" the emoji is : "+str(best_emoji)+" with distance of "+str(min_distance)+"!") + return best_emoji + + #else: + #print("WRONG SENTIMENT VECTOR") + + +# In[58]: + + +def show_demo(): + df_filtered = df[df["Unicode block"]=="Emoticons"] + all_smilies = list(df_filtered["Emoji"]) + + d_m = np.zeros(shape=(len(all_smilies),len(all_smilies))) + + for c1 in range(len(all_smilies)): + for c2 in range(len(all_smilies)): + e1 = all_smilies[c1] + e2 = all_smilies[c2] + + d = emoji_distance(e1,e2) + d_m[c1,c2] = d + + for c in range(len(d_m[0])): + emoji = all_smilies[c] + row = d_m[c] + row_sorted = np.argsort(row) + #closest 5 + r = row_sorted[0:10] + #print() + closest = "" + for i in r: + closest+=all_smilies[i] + print(emoji+": "+closest) + + +# In[60]: + + +#show_demo() + + +# In[61]: + + +#test bipolar matching entiment vector vs. emoji +#df_filtered = df[df["Unicode block"]=="Emoticons"] +#all_smilies = list(df_filtered["Emoji"]) +#for e in all_smilies: +# v2 = emoji_to_sentiment_vector(e) +# sentiment_vector_to_emoji(v2)