mkcloud 库中通过连接第三方公司的API实现了一个简单的聊天机器人,该程序能够与用户进行一定程度的对话。
from snownlp import SnowNLP
import mkcloud
while True:
say = input("你要说点什么:")
s1 = SnowNLP(say)
print("你的发言积极性为:",s1.sentiments)
response = mkcloud.robot.chat(say)
text1 = response
s2 = SnowNLP(text1)
print(response)
print("回复的积极性为:",s2.sentiments)