DHRUV SHEKHAWAT commited on
Commit
49f3a23
·
1 Parent(s): bcbbd47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -15
app.py CHANGED
@@ -79,34 +79,27 @@ if option == '1':
79
  chatbot.load_weights("predict3")
80
  chatbot.build(input_shape=(None, max_len)) # Build the model
81
  chatbot.compile(optimizer="adam", loss="sparse_categorical_crossentropy")
82
- other_text1 = text
83
  for i in range(1):
84
-
85
  other_text1 = other_text1.lower()
86
  other_words1 = other_text1.split()
87
- if len(other_words1) > 1:
88
- st.write("Error: Found more than 1 word . There should not be more than one word in the prompt ")
89
- for word in other_words1:
90
- if word not in word_to_num:
91
- st.write("Error: The word ` ",word," ` doesn't exist in the vocabulary and hence the model wasn't train on that. ")
92
- else:
93
- other_num1 = word_to_num[word]
94
-
95
  given_X1 = other_num1
96
  input_sequence1 = pad_sequences([given_X1], maxlen=max_len, padding='post')
97
- output_sentence = other_text1 + ""
98
- for _ in range(16):
99
  predicted_token = np.argmax(chatbot.predict(input_sequence1), axis=-1)
100
  predicted_token = predicted_token.item()
101
  out = num_to_word[predicted_token]
102
-
103
-
104
- output_sentence += " " + out
105
  if out == ".":
106
  break
 
 
107
  given_X1 = given_X1[1:]
108
  given_X1.append(predicted_token)
109
  input_sequence1 = pad_sequences([given_X1], maxlen=max_len, padding='post')
 
110
  out = output_sentence
111
 
112
 
 
79
  chatbot.load_weights("predict3")
80
  chatbot.build(input_shape=(None, max_len)) # Build the model
81
  chatbot.compile(optimizer="adam", loss="sparse_categorical_crossentropy")
82
+
83
  for i in range(1):
84
+ other_text1 = text
85
  other_text1 = other_text1.lower()
86
  other_words1 = other_text1.split()
87
+ other_num1 = [word_to_num[word] for word in other_words1]
 
 
 
 
 
 
 
88
  given_X1 = other_num1
89
  input_sequence1 = pad_sequences([given_X1], maxlen=max_len, padding='post')
90
+ output_sentence = other_text1+""
91
+ for _ in range(15):
92
  predicted_token = np.argmax(chatbot.predict(input_sequence1), axis=-1)
93
  predicted_token = predicted_token.item()
94
  out = num_to_word[predicted_token]
 
 
 
95
  if out == ".":
96
  break
97
+
98
+ output_sentence += " " + out
99
  given_X1 = given_X1[1:]
100
  given_X1.append(predicted_token)
101
  input_sequence1 = pad_sequences([given_X1], maxlen=max_len, padding='post')
102
+
103
  out = output_sentence
104
 
105