-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.py
More file actions
30 lines (25 loc) · 807 Bytes
/
core.py
File metadata and controls
30 lines (25 loc) · 807 Bytes
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
import re, nltk
def greet():
input = ("Hello, what would you like to do?")
return input
def contains(w):
return re.compile(r'\b({0})\b'.format(w), flags=re.IGNORECASE).search
def grant(request):
verb,noun = getRequest(request)
print(verb)
if verb.lower() == "turn":
print("Yes I can turn on the %s" % noun)
else:
print('Don\'t know how to do that yet')
def processRequest(text):
tokenizedText = nltk.word_tokenize(text)
print(nltk.pos_tag(tokenizedText))
return nltk.pos_tag(tokenizedText)
def getRequest(text):
for items in processRequest(text):
i = items[1]
if (i == 'VB' or i == 'VBP'):
verb = str(items[0]).lower()
if (i == 'NN'):
noun = str(items[0]).lower()
return verb, noun