-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
63 lines (49 loc) · 1.79 KB
/
utils.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from string import digits
import re
emoji_pattern = re.compile("["
u"\U0001F600-\U0001F64F" # emoticons
u"\U0001F300-\U0001F5FF" # symbols & pictographs
u"\U0001F680-\U0001F6FF" # transport & map symbols
u"\U0001F1E0-\U0001F1FF" # flags (iOS)
"]+", flags=re.UNICODE)
def clean_text(text: str) -> str:
text = text.lower()
text = re.sub('http://\S+|https://\S+', '', text)
text = text.replace(u',', '')
text = text.replace(u'"', '')
text = text.replace(u'(', '')
text = text.replace(u')', '')
text = text.replace(u'"', '')
text = text.replace(u':', '')
text = text.replace(u"'", '')
text = text.replace(u"‘‘", '')
text = text.replace(u"’’", '')
text = text.replace(u"''", '')
text = text.replace(u'-', '')
text = text.replace(u"\n","")
text = text.replace(u'.', '')
text = text.replace(u"?","")
text = text.replace(u"\\n","")
text = text.replace(u"[", "")
text = text.replace(u"]", "")
text = text.replace(u'#', "")
text = text.replace(u'@', "")
text = re.sub(r'[0-9]+', '', text)
text = emoji_pattern.sub(r'', text)
return text
def get_class_dicts():
a = ['activate', 'bring', 'change language', 'deactivate', 'decrease',
'increase']
o = ['Chinese', 'English', 'German', 'Korean', 'heat', 'juice', 'lamp',
'lights', 'music', 'newspaper', 'none', 'shoes', 'socks', 'volume']
l = ['bedroom', 'kitchen', 'none', 'washroom']
class_dict_a = {}
class_dict_o = {}
class_dict_l = {}
for num, i in enumerate(a):
class_dict_a[i] = num
for num, j in enumerate(o):
class_dict_o[j] = num
for num, k in enumerate(l):
class_dict_l[k] = num
return class_dict_a, class_dict_o, class_dict_l