我正在研究名为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
1 回答
我觉得这很有效 - >
但不是使用回复,而是使用问题:-)