datasciencedojo commited on
Commit
cc26dda
·
1 Parent(s): c6c855c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -31,6 +31,20 @@ model.load("MentalHealthChatBotmodel.tflearn")
31
  # print('model loaded successfully')
32
 
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  def chat(message, history):
35
  history = history or []
36
  message = message.lower()
 
31
  # print('model loaded successfully')
32
 
33
 
34
+ def bag_of_words(s, words):
35
+ bag = [0 for _ in range(len(words))]
36
+
37
+ s_words = nltk.word_tokenize(s)
38
+ s_words = [stemmer.stem(word.lower()) for word in s_words]
39
+
40
+ for se in s_words:
41
+ for i, w in enumerate(words):
42
+ if w == se:
43
+ bag[i] = 1
44
+
45
+ return np.array(bag)
46
+
47
+
48
  def chat(message, history):
49
  history = history or []
50
  message = message.lower()