I have created a simple chatbot and so far it is working good. The problem is, if I type for example "hibernate", the script will recognize this as a greetings. I am German and we have a lot of words containing "hi".
This is my Python code:
import json
import random
eingabe = input('DU: ')
eingabe = eingabe.lower()
with open('ebaykleinanzeigen\intents.json') as file:
data = json.load(file)
for intent in data['intents']:
for pattern in intent['patterns']:
if pattern in eingabe:
antwort = random.choice(intent['responses'])
print(antwort)
def getReply(eingabe):
for intent in data['intents']:
for pattern in intent['patterns']:
if pattern in eingabe:
antwort = random.choice(intent['responses'])
print(antwort)
while 'beenden' not in eingabe:
eingabe = input('DU: ')
eingabe = eingabe.lower()
getReply(eingabe)
And this is my JSON file:
{"intents": [
{"tag": "gruessen",
"patterns": ["hi"],
"responses": ["Hi!"]
}
]
}
Thanks in advance.