forked from eenu5/medbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathonlyMethods.py
More file actions
46 lines (36 loc) · 1002 Bytes
/
Copy pathonlyMethods.py
File metadata and controls
46 lines (36 loc) · 1002 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def stopWords(text):
#text is a sentence
stopw = set(stopwords.words('english'))
filtered = []
words = word_tokenize(text)
for i in words:
if i not in stopw:
filtered.append(i)
return filtered
def stemming(text):
#text could be a sent or word
ps = PorterStemmer()
empty = []
for w in text:
empty.append(w)
return empty
def getName(text):
#text is a/many sentence
#takes the user response and returns name of the user
filtered = stopWords(text)
stemmed = stemming(filtered)
print("stemmed",stemmed)
for w in stemmed:
if w.lower() != 'name':
print(w)
tag = nltk.pos_tag(w)
namedEntity = nltk.ne_chunk(tag, binary=True)
print('namesd',namedEntity)
def greet():
k = np.random.randint(50)
print(gd[k%11])
def askName():
k = np.random.randint(50)
print(nd[k%7])
inp = input()
return inp