How to use emot - 6 common examples

To help you get started, we’ve selected a few emot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NeelShah18 / emot / emot / core.py View on Github external
def emoji(string):
    '''emot.emoji is use to detect emoji from text

        >>> text = "I love python 👨 :-)"
        >>> emot.emoji(text)
        >>> {'value': ['👨'], 'mean': [':man:'], 'location': [[14, 14]], 'flag': True}
    '''
    __entities = {}
    __value = []
    __mean = []
    __location = []
    flag = True
    try:
        pro_string = str(string)
        for pos,ej in enumerate(pro_string):
            if ej in emo_unicode.UNICODE_EMO:
                try:
                    __value.append(ej)
                    __mean.append(emo_unicode.UNICODE_EMO[ej])
                    __location.append([pos,pos])
                except Exception as e:
                    flag = False
                    __entities.append({"flag": False})
                    return __entities

    except Exception as e:
        flag = False
        __entities.append({"flag": False})
        return __entities
    if len(__value) < 1:
        flag = False    
    __entities = {
github NeelShah18 / emot / emot / core.py View on Github external
def emoticons(string):
    '''emot.emoticons is use to detect emoticons from text

        >>> text = "I love python 👨 :-)"
        >>> emot.emoticons(text)
        >>> {'value': [':-)'], 'location': [[16, 19]], 'mean': ['Happy face smiley'], 'flag': True}
    '''
    __entities = []
    flag = True
    try:
        pattern = u'(' + u'|'.join(k for k in emo_unicode.EMOTICONS) + u')'
        __entities = []
        __value = []
        __location = []
        matches = re.finditer(r"%s"%pattern,str(string))
        for et in matches:
            __value.append(et.group().strip())
            __location.append([et.start(),et.end()])
            
        __mean = []
        for each in __value:
            __mean.append(emo_unicode.EMOTICONS_EMO[each])
        
        if len(__value) < 1:
            flag = False
        __entities = {
        'value' : __value,
github NeelShah18 / emot / emot / core.py View on Github external
'''
    __entities = []
    flag = True
    try:
        pattern = u'(' + u'|'.join(k for k in emo_unicode.EMOTICONS) + u')'
        __entities = []
        __value = []
        __location = []
        matches = re.finditer(r"%s"%pattern,str(string))
        for et in matches:
            __value.append(et.group().strip())
            __location.append([et.start(),et.end()])
            
        __mean = []
        for each in __value:
            __mean.append(emo_unicode.EMOTICONS_EMO[each])
        
        if len(__value) < 1:
            flag = False
        __entities = {
        'value' : __value,
        'location' : __location,
        'mean' : __mean,
        'flag' : flag
        }
    except Exception as e:
        __entities = [{'flag' : False}]
        #print("No emoiticons found")
        return __entities

    return __entities
github NeelShah18 / emot / emot / core.py View on Github external
>>> text = "I love python 👨 :-)"
        >>> emot.emoji(text)
        >>> {'value': ['👨'], 'mean': [':man:'], 'location': [[14, 14]], 'flag': True}
    '''
    __entities = {}
    __value = []
    __mean = []
    __location = []
    flag = True
    try:
        pro_string = str(string)
        for pos,ej in enumerate(pro_string):
            if ej in emo_unicode.UNICODE_EMO:
                try:
                    __value.append(ej)
                    __mean.append(emo_unicode.UNICODE_EMO[ej])
                    __location.append([pos,pos])
                except Exception as e:
                    flag = False
                    __entities.append({"flag": False})
                    return __entities

    except Exception as e:
        flag = False
        __entities.append({"flag": False})
        return __entities
    if len(__value) < 1:
        flag = False    
    __entities = {
        'value' : __value,
        'mean' : __mean,
        'location' : __location,
github nouhadziri / THRED / thred / util / nlp.py View on Github external
def _strip_emojis(text):
    emojis = set([emoji['value'] for emoji in emot.emoji(text)])

    normalized = text
    for emoji in emojis:
        normalized = normalized.replace(emoji, '')

    return normalized
github nouhadziri / THRED / thred / util / nlp.py View on Github external
def _strip_emoticons(text):
    global UNCOMMON_EMOTICONS

    tokens = tweet_tokenize(text)

    emoticons = set()
    for token in tokens:
        for em in emot.emoticons(token):
            emoticon = em['value']
            if emoticon in ('(', ')', ':') or emoticon != token:
                continue
            emoticons.add(emoticon)

        if Emoticon_RE.match(token) or token in (':*(',):
            emoticons.add(token)

    for em in UNCOMMON_EMOTICONS:
        if em in text:
            emoticons.add(em)

    normalized = text
    for emoticon in emoticons:
        if re.match(r'^[a-zA-Z0-9]+$', emoticon.lower()):
            continue

emot

Emoji and Emoticons detection package for Python

MIT
Latest version published 1 year ago

Package Health Score

61 / 100
Full package analysis