我正在开发一个聊天机器人,只是想看看效果如何。我使用的是PyAIML模块。目前我正在尝试获取用户的名字,并在需要时使用它。然而,当我运行程序时,它不会显示名字,只会显示周围的文本。请原谅我对问题的描述不够清楚。让我展示一些代码给你看。
<category><pattern>MY NAME IS *</pattern><template>ok <star/>, I will do my best to remember that <star/> is your name.</template><think><set name = "name"><star/></set></think></category><category><pattern>WHAT IS MY NAME</pattern><template>I like to call you <get name = "name"/>. should I change it? </template></category>
运行时,输出不包括名字。所有显示的内容是:
<--I like to call you . Should I change it?
我做错了什么吗?
附言:(请温柔点,我今天才开始学习AIML :))
回答:
我不确定“think”标签是用来做什么的,但我认为主要问题是你把“set”标签放在了“template”标签之外。
试试这样做:
<template>ok <set name = "name"><star/></set>, I will do my best to remember that <get name = "name"/> is your name.</template>