def get_random_emoji(): return (random.choice(list(UNICODE_EMOJI.keys())))
def get_unicode_emoji_from_text(text): emojis = [] for char in text: if char in UNICODE_EMOJI.keys(): emojis.append(char) return emojis
def replace_emoji(x): if x in UNICODE_EMOJI.keys(): return ' ' + UNICODE_EMOJI[x].replace(':', '@') + ' ' else: return x
from redis import StrictRedis import emoji from parsers import EMOJI_NAMES_PATTERN # TODO: use dotenv redis = StrictRedis() auth = OAuthHandler( '', '' ) auth.set_access_token( '', '' ) words = list(UNICODE_EMOJI.keys())[:400] class EmojiStream(StreamListener): def on_status(self, status): # TODO: avoid duplicate tweets tweet = status.text language = 'en' if not status.retweeted and 'RT @' not in tweet: try: language = lang(tweet) except LangDetectException: pass