{ "info": { "author": "Brad Solomon", "author_email": "brad.solomon.1124@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Text Processing", "Topic :: Utilities" ], "description": "# demoji\n\nAccurately find or remove [emojis](https://en.wikipedia.org/wiki/Emoji) from a blob of text.\n\n[![License](https://img.shields.io/github/license/bsolomon1124/demoji.svg)](https://github.com/bsolomon1124/demoji/blob/master/LICENSE)\n[![PyPI](https://img.shields.io/pypi/v/demoji.svg)](https://pypi.org/project/demoji/)\n[![Status](https://img.shields.io/pypi/status/demoji.svg)](https://pypi.org/project/demoji/)\n[![Python](https://img.shields.io/pypi/pyversions/demoji.svg)](https://pypi.org/project/demoji)\n\n-------\n\n## Basic Usage\n\n`demoji` requires an initial data download from the Unicode Consortium's [emoji code repository](http://unicode.org/Public/emoji/12.0/emoji-test.txt).\n\nOn first use of the package, call `download_codes()`:\n\n```python\n>>> import demoji\n>>> demoji.download_codes()\nDownloading emoji data ...\n... OK (Got response in 0.14 seconds)\nWriting emoji data to /Users/brad/.demoji/codes.json ...\n... OK\n```\n\nThis will store the Unicode hex-notated symbols at `~/.demoji/codes.json` for future use.\n\n`demoji` exports two text-related functions, `findall()` and `replace()`, which behave somewhat the `re` module's `findall()` and `sub()`, respectively. However, `findall()` returns a dictionary of emojis to their full name (description):\n\n```python\n>>> tweet = \"\"\"\\\n... #startspreadingthenews yankees win great start by \ud83c\udf85\ud83c\udffe going 5strong innings with 5k\u2019s\ud83d\udd25 \ud83d\udc02\n... solo homerun \ud83c\udf0b\ud83c\udf0b with 2 solo homeruns and\ud83d\udc79 3run homerun\u2026 \ud83e\udd21 \ud83d\udea3\ud83c\udffc \ud83d\udc68\ud83c\udffd\u200d\u2696\ufe0f with rbi\u2019s \u2026 \ud83d\udd25\ud83d\udd25\n... \ud83c\uddf2\ud83c\uddfd and \ud83c\uddf3\ud83c\uddee to close the game\ud83d\udd25\ud83d\udd25!!!\u2026.\n... WHAT A GAME!!..\n... \"\"\"\n>>> demoji.findall(tweet)\n{\n \"\ud83d\udd25\": \"fire\",\n \"\ud83c\udf0b\": \"volcano\",\n \"\ud83d\udc68\ud83c\udffd\\u200d\u2696\ufe0f\": \"man judge: medium skin tone\",\n \"\ud83c\udf85\ud83c\udffe\": \"Santa Claus: medium-dark skin tone\",\n \"\ud83c\uddf2\ud83c\uddfd\": \"flag: Mexico\",\n \"\ud83d\udc79\": \"ogre\",\n \"\ud83e\udd21\": \"clown face\",\n \"\ud83c\uddf3\ud83c\uddee\": \"flag: Nicaragua\",\n \"\ud83d\udea3\ud83c\udffc\": \"person rowing boat: medium-light skin tone\",\n \"\ud83d\udc02\": \"ox\",\n}\n```\n\nThe reason that `demoji` requires a download rather than coming pre-packaged with Unicode emoji data is that the emoji list itself is frequently updated and changed. You are free to periodically update the local cache by calling `demoji.download_codes()` every so often.\n\nTo pull your last-downloaded date, you can use the `last_downloaded_timestamp()` helper:\n\n```python\n>>> demoji.last_downloaded_timestamp()\ndatetime.datetime(2019, 2, 9, 7, 42, 24, 433776, tzinfo=)\n```\n\nThe result will be `None` if codes have not previously been downloaded.\n\n## Footnote: Emoji Sequences\n\nNumerous emojis that look like single Unicode characters are actually multi-character sequences. Examples:\n\n- The keycap 2\ufe0f\u20e3 is actually 3 characters, U+0032 (the ASCII digit 2), U+FE0F (variation selector), and U+20E3 (combining enclosing keycap).\n- The flag of Scotland 7 component characters, `b'\\\\U0001f3f4\\\\U000e0067\\\\U000e0062\\\\U000e0073\\\\U000e0063\\\\U000e0074\\\\U000e007f'` in full esaped notation.\n\n(You can see any of these through `s.encode(\"unicode-escape\")`.)\n\n`demoji` is careful to handle this and should find the full sequences rather than their incomplete subcomponents.\n\nThe way it does this it to sort emoji codes by their length, and then compile a concatenated regular expression that will greedily search for longer emojis first, falling back to shorter ones if not found. This is not by any means a super-optimized way of searching as it has O(N2) properties, but the focus is on accuracy and completeness.\n\n```python\n>>> from pprint import pprint\n>>> seq = \"\"\"\\\n... I bet you didn't know that \ud83d\ude4b, \ud83d\ude4b\u200d\u2642\ufe0f, and \ud83d\ude4b\u200d\u2640\ufe0f are three different emojis.\n... \"\"\"\n>>> pprint(seq.encode('unicode-escape')) # Python 3\n(b\"I bet you didn't know that \\\\U0001f64b, \\\\U0001f64b\\\\u200d\\\\u2642\\\\ufe0f,\"\n b' and \\\\U0001f64b\\\\u200d\\\\u2640\\\\ufe0f are three different emojis.\\\\n')\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/bsolomon1124/demoji", "keywords": "emoji,emojis,nlp,natural langauge processing,unicode", "license": "Apache 2.0", "maintainer": "", "maintainer_email": "", "name": "demoji", "package_url": "https://pypi.org/project/demoji/", "platform": "", "project_url": "https://pypi.org/project/demoji/", "project_urls": { "Homepage": "https://github.com/bsolomon1124/demoji" }, "release_url": "https://pypi.org/project/demoji/0.1.5/", "requires_dist": [ "requests (<3.0.0)", "setuptools" ], "requires_python": "", "summary": "Accurately remove and replace emojis in text strings.", "version": "0.1.5" }, "last_serial": 5225751, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "cea0992d06ff943417e98c0c0f679340", "sha256": "72cb5c293e4dac28e4f0210e9608f08b52fd48aa7ed6bdd3f475490a901e932f" }, "downloads": -1, "filename": "demoji-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "cea0992d06ff943417e98c0c0f679340", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7416, "upload_time": "2019-02-09T03:25:38", "url": "https://files.pythonhosted.org/packages/3a/49/87dbc21a04865e61941b3bec9b1f15826aef2a37e80fa40f5d31aa238a6b/demoji-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2803716643a79c71130fbf3283f5dc54", "sha256": "e168c828dc2bf12a53a863fdfd1f56a8628f6451b1e9a9f689162038e35ba61b" }, "downloads": -1, "filename": "demoji-0.0.1.tar.gz", "has_sig": false, "md5_digest": "2803716643a79c71130fbf3283f5dc54", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3082, "upload_time": "2019-02-09T03:25:40", "url": "https://files.pythonhosted.org/packages/af/6c/06484504bf122c029f2e7b3b3f1a185c60a67bddc2fb3a5e3408c6a19a28/demoji-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "498d8b8cb70153a7eff07b752f16c9aa", "sha256": "fafacb82c5e73b8b0c52da59246095c0d79f5e87864781da5b9bdfc5a886f0d2" }, "downloads": -1, "filename": "demoji-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "498d8b8cb70153a7eff07b752f16c9aa", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7416, "upload_time": "2019-02-09T03:27:51", "url": "https://files.pythonhosted.org/packages/3e/7d/9699c2ba65e011d14978dae0baf36deb71a9b25b1536eeceebcb0a9970c5/demoji-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "66dadc4b244c72184ae6503f9c37b3f9", "sha256": "f7668fef3e383ffcd7466ae374bd5d12996cf27cfa5663a061a36e74e6764db4" }, "downloads": -1, "filename": "demoji-0.0.2.tar.gz", "has_sig": false, "md5_digest": "66dadc4b244c72184ae6503f9c37b3f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3082, "upload_time": "2019-02-09T03:27:52", "url": "https://files.pythonhosted.org/packages/5c/67/fe42264606eeb28d2cce4a0027a65b43d2697d2715ccf5991e390f3a12d5/demoji-0.0.2.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "c78515c5affd597a90e633b5dd392f58", "sha256": "e4ec906696899c4e9998b5b0b055c04276f7378d5503279043db5cae41776add" }, "downloads": -1, "filename": "demoji-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c78515c5affd597a90e633b5dd392f58", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9369, "upload_time": "2019-02-09T15:23:47", "url": "https://files.pythonhosted.org/packages/b5/0d/3549ab29a4f255691e82e6273e3cc463526e0d22646883765fcc4b830ef8/demoji-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "66e0cd985016e34c6f9c24d290c21365", "sha256": "97e1c00e5f2890b4a5016ade048a3aa79ddfdfef7bc2e2c7f783db2e17b19429" }, "downloads": -1, "filename": "demoji-0.1.1.tar.gz", "has_sig": false, "md5_digest": "66e0cd985016e34c6f9c24d290c21365", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5248, "upload_time": "2019-02-09T15:23:48", "url": "https://files.pythonhosted.org/packages/f2/b0/1e5f1cb44668c1475ff1ddfabe428819448cb6f139472cf81e4f81589275/demoji-0.1.1.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "4b5bead0d3b09822c7dc58e6a0732ac7", "sha256": "d813d9af06ada4d225a7e151415517e876c9b1bc28d28b6b51c3253666172ddf" }, "downloads": -1, "filename": "demoji-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "4b5bead0d3b09822c7dc58e6a0732ac7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9786, "upload_time": "2019-02-09T22:05:20", "url": "https://files.pythonhosted.org/packages/24/9b/96f2e220751b64937ee0a0d0519aa206fc57fa1d3d7305a545cab300f04e/demoji-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d92fe8b09e2ac2527fb547bd44785b92", "sha256": "046a742c7281fb21d667438da025374b1aa048967f833c963f885584d4c1252d" }, "downloads": -1, "filename": "demoji-0.1.3.tar.gz", "has_sig": false, "md5_digest": "d92fe8b09e2ac2527fb547bd44785b92", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5715, "upload_time": "2019-02-09T22:05:22", "url": "https://files.pythonhosted.org/packages/06/52/07f35ce1a4f9d252bc9d8884d0d22a3fd948331bb99c3d624770b56ed202/demoji-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "a48595523e281b3ce121acd2d70698ba", "sha256": "5f42d8b92ce260cf1a4566a6c254f22f8c5f21a06b7811cd8519af3a4ddbda23" }, "downloads": -1, "filename": "demoji-0.1.4-py3-none-any.whl", "has_sig": false, "md5_digest": "a48595523e281b3ce121acd2d70698ba", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9789, "upload_time": "2019-02-19T01:42:22", "url": "https://files.pythonhosted.org/packages/31/c9/48117ef774eb3216a0a5b051a81b7cde417770eb672f8aca1731d5464908/demoji-0.1.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "96854e2e862f2a7311970c60044c4d1d", "sha256": "afd2eac75a488664833216907adc43bbd858605152c0a954ff34ddee0259c558" }, "downloads": -1, "filename": "demoji-0.1.4.tar.gz", "has_sig": false, "md5_digest": "96854e2e862f2a7311970c60044c4d1d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5726, "upload_time": "2019-02-19T01:42:24", "url": "https://files.pythonhosted.org/packages/f8/84/08283cc6894b3a1660ecb3e2defc611c5238c791ac696b7292a8316874b1/demoji-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "991de645d6cce1aed23d6d1a471473fd", "sha256": "6d81bda178b0415141fae6f8e9da275e99dedbcd887d937eb7e8435c845fe644" }, "downloads": -1, "filename": "demoji-0.1.5-py3-none-any.whl", "has_sig": false, "md5_digest": "991de645d6cce1aed23d6d1a471473fd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9511, "upload_time": "2019-05-04T14:47:59", "url": "https://files.pythonhosted.org/packages/d7/32/87e7ca4d8a8462cb8a0cd8803cbe4933ce03e5e0e9e3e685f89df72a8110/demoji-0.1.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f6247c469177732b52908ec7e0f4644c", "sha256": "6509f777e4c0cf5794c799b5c4c355ff43df540d06b65570fc9675e46ebab82e" }, "downloads": -1, "filename": "demoji-0.1.5.tar.gz", "has_sig": false, "md5_digest": "f6247c469177732b52908ec7e0f4644c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5406, "upload_time": "2019-05-04T14:48:01", "url": "https://files.pythonhosted.org/packages/6b/cc/7721315f755ce031a32c3c4009c6d5c13fc90b592fb7a3d7b4be6dfc0a03/demoji-0.1.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "991de645d6cce1aed23d6d1a471473fd", "sha256": "6d81bda178b0415141fae6f8e9da275e99dedbcd887d937eb7e8435c845fe644" }, "downloads": -1, "filename": "demoji-0.1.5-py3-none-any.whl", "has_sig": false, "md5_digest": "991de645d6cce1aed23d6d1a471473fd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9511, "upload_time": "2019-05-04T14:47:59", "url": "https://files.pythonhosted.org/packages/d7/32/87e7ca4d8a8462cb8a0cd8803cbe4933ce03e5e0e9e3e685f89df72a8110/demoji-0.1.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f6247c469177732b52908ec7e0f4644c", "sha256": "6509f777e4c0cf5794c799b5c4c355ff43df540d06b65570fc9675e46ebab82e" }, "downloads": -1, "filename": "demoji-0.1.5.tar.gz", "has_sig": false, "md5_digest": "f6247c469177732b52908ec7e0f4644c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5406, "upload_time": "2019-05-04T14:48:01", "url": "https://files.pythonhosted.org/packages/6b/cc/7721315f755ce031a32c3c4009c6d5c13fc90b592fb7a3d7b4be6dfc0a03/demoji-0.1.5.tar.gz" } ] }