def valid(data): alt = data["alt"] title = data["title"] parsed = emojificate(alt) assert alt in parsed assert 'alt="{}'.format(alt) in parsed assert title in parsed assert 'aria-label="Emoji: {}'.format(title) in parsed
def valid(emoji, title, fuzzy=False): parsed = emojificate(emoji) assert emoji in parsed assert 'alt="{}'.format(emoji) in parsed assert title in parsed if not fuzzy: assert 'aria-label="Emoji: {}'.format(title) in parsed
def emoji_mapper(tweet): tweet = tweet.replace('\"', ' ') returned_text = emojificate(tweet) emojis = re.findall(r'<img.*?>', str(returned_text)) if emojis: for emoji in emojis: matched_emoji = re.match(r'.*title="(.*?)".*', emoji).group(1) returned_text = returned_text.replace(emoji, ' ' + matched_emoji + ' ') return returned_text
def parseEmojis(tweet): ptweet = emojificate(tweet) matches = ptweet.split("Emoji:") toret = [] for m in matches: #print ("zzz" + m) sindx = m.find("title=") eindx = m.find(" aria-label=") if sindx > 0 and eindx > 0: toret.append(m[sindx:eindx].replace("title=", "")) return toret
def test_nochange(): for phrase in TEST_NOCHANGE: parsed = emojificate(phrase) assert phrase == parsed
def valid(phrase): parsed = emojificate(phrase) assert phrase != parsed