示例#1
0
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
示例#2
0
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
示例#3
0
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
示例#4
0
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
示例#5
0
def test_nochange():
    for phrase in TEST_NOCHANGE:
        parsed = emojificate(phrase)
        assert phrase == parsed
示例#6
0
def valid(phrase):
    parsed = emojificate(phrase)
    assert phrase != parsed