Update app.py
Browse files
app.py
CHANGED
|
@@ -35,13 +35,16 @@ else:
|
|
| 35 |
result = model.predict(keras.preprocessing.sequence.pad_sequences(tokenizer.texts_to_sequences([question]),
|
| 36 |
truncating='post', maxlen=max_len))
|
| 37 |
|
|
|
|
| 38 |
idk = ['عذراً، لا يمكنني الإجابة عن السؤال المطروح', 'عذراً، لم أفهم سؤالك']
|
|
|
|
| 39 |
if result[0][np.argmax(result)] < 0.65: # if perplexity is high
|
| 40 |
st.write(np.random.choice(idk))
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
| 35 |
result = model.predict(keras.preprocessing.sequence.pad_sequences(tokenizer.texts_to_sequences([question]),
|
| 36 |
truncating='post', maxlen=max_len))
|
| 37 |
|
| 38 |
+
|
| 39 |
idk = ['عذراً، لا يمكنني الإجابة عن السؤال المطروح', 'عذراً، لم أفهم سؤالك']
|
| 40 |
+
|
| 41 |
if result[0][np.argmax(result)] < 0.65: # if perplexity is high
|
| 42 |
st.write(np.random.choice(idk))
|
| 43 |
+
|
| 44 |
+
else:
|
| 45 |
+
tag = lbl_encoder.inverse_transform([np.argmax(result)])
|
| 46 |
+
|
| 47 |
+
for i in data['intents']:
|
| 48 |
+
if i['tag'] == tag:
|
| 49 |
+
out = np.random.choice(i['responses'])
|
| 50 |
+
st.write(out)
|