我正在开发名为 Chatterbot 的 Python 库。当我收到回复时,如何以编程方式增加对它的信心,以便在再次向其发布相同类型的问题时它会回答相同的答案。简而言之,我应该如何告诉聊天机器人这是正确的答案,而这不是正确的答案,否则它将假设错误答案是正确的答案并增加对它的信心。供您参考,我能够获得回复的信心,但信心的增加不起作用,因为它每次都表现出相同的信心。我的代码如下 -
while True:
request = str(input(username+": "))
list_of_words = request.split(' ')
for i in list_of_words:
if i in happy_list:
happy_count += 1
elif i in sad_list:
sad_count += 1
if request.strip() != 'bye' and request.strip() != 'Bye' and request.strip() != 'ok bye' and request.strip() != 'see you' and request.strip() != 'see ya':
response = bot.get_response(request)
print("Joe: ",response)
print(response.confidence)
response.confidence = response.confidence + 0.1
if happy_count >= 4 or sad_count >= 4:
if happy_count >= 4:
print("Joe: You seems to be very happy today",username)
happy_count = 0
elif sad_count >=4:
print("Joe: What happened? Are you upset",username,"?")
sad_count = 0
else:
print("Joe: Ya taddah")
break