Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def random_emoji():
# Don't return a random flag (hence the `islower`)
emojis = [
e
for e, unicode in emoji.UNICODE_EMOJI.items()
if unicode[1].islower() and len(e) == 1
]
return random.choice(emojis)
# coding: utf8
from __future__ import unicode_literals
from spacy.tokens import Doc, Span, Token
from spacy.matcher import PhraseMatcher
from emoji import UNICODE_EMOJI
from .about import __version__
# make sure multi-character emoji don't contain whitespace
EMOJI = {e.replace(' ', ''): t for e, t in UNICODE_EMOJI.items()}
class Emoji(object):
"""spaCy v2.0 pipeline component for adding emoji meta data to `Doc` objects.
Detects emoji consisting of one or more unicode characters, and can
optionally merge multi-char emoji (combined pictures, emoji with skin tone
modifiers) into one token. Emoji are matched using spaCy's `PhraseMatcher`,
and looked up in the data table provided by the "emoji" package:
https://github.com/carpedm20/emoji
USAGE:
>>> import spacy
>>> from spacymoji import Emoji
>>> nlp = spacy.load('en')
>>> emoji = Emoji(nlp)
>>> nlp.add_pipe(emoji, first=True)