Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 = {
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,
'''
__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
>>> 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,
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
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