-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFirstChatBot.py
70 lines (49 loc) · 1.63 KB
/
FirstChatBot.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
63
64
65
66
67
68
69
70
import numpy as np
import pandas as pd
import nltk
import dialogflow
from nltk.corpus import stopwords
from nltk.stem import SnowballStemmer
snowball_stemmer = SnowballStemmer('english')
def remove_stopwords(text):
words = text.split()
meaningful_words = [w for w in words if w not in stopwords.words("english")]
return meaningful_words
def text_process(text_input):
# Remove stopwords
print(text_input)
text_input = remove_stopwords(text_input)
for i, word in enumerate(text_input):
print(word)
text_input[i] = snowball_stemmer.stem(word)
text_input = list(set(text_input))
print(text_input)
# Check keywords
flag1 = False
for w in text_input:
if w in ['company', 'packages', 'price']:
flag1 = True
if flag1:
text = respond_packages()
print(text)
end_signal = False
return end_signal
def respond_packages():
text = 'We provide 5 different career packages, they are:\n'\
'1. Career Exploration\n'\
'2. Hybrid Training Satisfaction GUARANTEE\n'\
'3. 1-Month Resume Success GUARANTEE\n'\
'4. 3-Month Elite Job Success GUARANTEE\n'\
'5. 1-Month Sprint to Success GUARANTEE\n'
return text
def respond_three_month():
text = 'The 3-Month Elite Job Success GUARANTEE is priced dynamically\n'\
'Based on the future offer you would get, '
return text
def main():
q1 = input("Hi, how can i help you today?")
program_run = True
while program_run: # Run input digest process
program_run = text_process(q1)
if __name__ == '__main__':
main()