-
Notifications
You must be signed in to change notification settings - Fork 0
/
question.py
61 lines (46 loc) · 1.48 KB
/
question.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
from nltk.tokenize import word_tokenize
from nltk.tag import pos_tag
from nltk.corpus import stopwords
import random
import sqlite3
#flags
# Sentences we'll respond with if the user greeted us
GREETING_KEYWORDS = ("hello", "hi", "greetings", "sup", "what's up","yo")
GREETING_RESPONSES = ["'sup", "hey", "*nods*", ]
RESPONSES = ["What can I do for you?","How can I help?","What can I help you with?"]
WEATHER_KEYWORDS = ["climate","weather","forecast"]
def check_for_greeting(sentence):
"""If any of the words in the user's input was a greeting, return a greeting response"""
for word in sentence:
g_flag = 0
w_flag = 0
d_flag = 0
if g_flag == 0:
if word in GREETING_KEYWORDS:
g_flag = 1
return random.choice(GREETING_RESPONSES),random.choice(RESPONSES)
## elif word in WEATHER_KEYWORDS:
## w_flag = 1
## return
## elif word in
##
## for word in sentence:
## if word in WEATHER_KEYWORDS:
##
##
##
##
##
## else:
## return 1
##
##def weather_api(location):
##
#qry = 'hi bot'
def processing(qry):
words = word_tokenize(qry) #words = ['hi', 'bot']
tagged_query = pos_tag(words)#tagged_query = [('hi', 'NN'), ('bot', 'NN')]
reply = check_for_greeting(tagged_query)
## temperature = check_for_temperature()
## dictionary = check_for_meaning()
return reply