-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathta_emoticons.py
34 lines (28 loc) · 911 Bytes
/
ta_emoticons.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 17 13:34:39 2017
@author: Luis Carlos Prieto
"""
import ta_ConfigManager
class EmoticonDetector:
emoticons = {}
miConf = ta_ConfigManager.Configuracion()
def __init__(self, emoticon_file=miConf.m_Emoticonos):
from pathlib import Path
content = Path(emoticon_file).read_text()
positive = True
for line in content.split("\n"):
if "positivo" in line.lower():
positive = True
continue
elif "negativo" in line.lower():
positive = False
continue
self.emoticons[line] = positive
def is_positive(self, emoticon):
if emoticon in self.emoticons:
return self.emoticons[emoticon]
return False
def is_emoticon(self, to_check):
return to_check in self.emoticons