ipvikas commited on
Commit
41530a1
1 Parent(s): 9239d24

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -19,12 +19,12 @@ nltk.download('punkt')
19
  from nltk.stem.porter import PorterStemmer
20
  stemmer = PorterStemmer()
21
 
22
- def tokenize(sentence):
23
  """
24
  split sentence into array of words/tokens
25
  a token can be a word or punctuation character, or number
26
  """
27
- return nltk.word_tokenize(sentence)
28
 
29
  # print(tokenize('Hello how are you'))
30
 
@@ -294,9 +294,9 @@ bot_name = "Sam"
294
 
295
 
296
 
297
- def get_response(input_text):
298
- sentence = tokenize(input_text)
299
- X = bag_of_words(sentence, all_words)
300
  X = X.reshape(1, X.shape[0])
301
  X = torch.from_numpy(X).to(device)
302
 
@@ -317,12 +317,12 @@ def get_response(input_text):
317
  print("Let's chat! (type 'quit' to exit)")
318
  while True:
319
  # sentence = "do you use credit cards?"
320
- sentence = input("You: ")
321
- if sentence == "quit":
322
  break
323
 
324
- sentence = tokenize(sentence)
325
- X = bag_of_words(sentence, all_words)
326
  X = X.reshape(1, X.shape[0])
327
  X = torch.from_numpy(X).to(device)
328
 
 
19
  from nltk.stem.porter import PorterStemmer
20
  stemmer = PorterStemmer()
21
 
22
+ def tokenize(input_text):
23
  """
24
  split sentence into array of words/tokens
25
  a token can be a word or punctuation character, or number
26
  """
27
+ return nltk.word_tokenize(input_text)
28
 
29
  # print(tokenize('Hello how are you'))
30
 
 
294
 
295
 
296
 
297
+ def get_response(msg):
298
+ input_text= tokenize(msg)
299
+ X = bag_of_words(input_text, all_words)
300
  X = X.reshape(1, X.shape[0])
301
  X = torch.from_numpy(X).to(device)
302
 
 
317
  print("Let's chat! (type 'quit' to exit)")
318
  while True:
319
  # sentence = "do you use credit cards?"
320
+ input_text= input("You: ")
321
+ if input_text== "quit":
322
  break
323
 
324
+ input_text= tokenize(input_text)
325
+ X = bag_of_words(input_text, all_words)
326
  X = X.reshape(1, X.shape[0])
327
  X = torch.from_numpy(X).to(device)
328