-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMessageParser.py
53 lines (48 loc) · 1.38 KB
/
MessageParser.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
UNKNOWN_MSG = -1
GREETING_MSG = 0
UPCOMING_IPO = 1
ALL_IPO = 2
TODAYS_IPO = 3
IPO_NAME = 4
IPO_MONTH = 5
UNSUBSCRIBE = 6
SUBSCRIBE = 7
HELP = 8
THANKS = 9
greeting_keywords = ['hi', 'hello', 'hey', 'whats', 'wassup','get started']
curr_keywords = ["upcoming"]
all_keywords = ["recent ipo"]
thanks_keywords = ['thank you','thanks']
today_keyword = ["today", "current"]
ipo_name = ["ipo"]
ipo_month = ["month"]
unsubscribe_keyword = ["remove me", "unsubscribe"]
subscribe_keyword = ["subscribe"]
help_keyword = ["help"]
def parse(text):
text = text.lower()
if any(x in text for x in greeting_keywords):
return GREETING_MSG
elif any(x in text for x in curr_keywords):
return UPCOMING_IPO
elif any(x in text for x in all_keywords):
return ALL_IPO
elif any(x in text for x in today_keyword):
return TODAYS_IPO
elif any(x in text for x in ipo_name):
return IPO_NAME
elif any(x in text for x in ipo_month):
return IPO_MONTH
elif any(x in text for x in unsubscribe_keyword):
return UNSUBSCRIBE
elif any(x in text for x in subscribe_keyword):
return SUBSCRIBE
elif any(x in text for x in help_keyword):
return HELP
elif any(x in text for x in thanks_keywords):
return THANKS
else:
return UNKNOWN_MSG
def parseIPOName(text):
text = text.upper()
return text[3:len(text)].strip()