关键词:Artificial Intelligence Markup Language、XML语言、Richard Wallace
关于安装:
1.安装Python
2.pip install aiml
关于使用【例子:创建一个AIML对话过程】:
1.创建任一个项目文件夹
2.创建std-startup.xml文件【固定】
<aiml version="1.0.1" encoding="UTF-8">
<category>
<pattern>LOAD AIML B</pattern>
<template>
<learn>basic_chat.aiml</learn>
</template>
</category>
</aiml>
3.创建上文中的basic_chat.aiml资源文件
<aiml version="1.0.1" encoding="UTF-8">
<category>
<pattern>1</pattern>
<template>12?</template>
</category>
<category>
<pattern>2*</pattern>
<template>2345?</template>
</category>
<category>
<pattern>*谢谢*</pattern>
<template>不客气,嘻嘻~</template>
</category>
</aiml>
4.创建对话执行的Python文件
import aiml
k=aiml.Kernel()
k.learn("std-startup.xml")
k.respond("LOAD AIML B")
while True:
print(k.respond(input("input >> ")))
5.关于报错:
AttributeError: module 'time' has no attribute 'clock'
解: Python3.8 不再支持time.clock,用 time.perf_counter() 来替换即可。
来源:AttributeError module ‘time‘ has no attribute ‘clock‘ 解决方法_叶庭云 成为自己的光-CSDN博客‘
6.其他参考【链接中有些源码中错误,要自我甄别修正】:
AIML环境安装设置 - AIML 教程 | BootWiki.com
Python 的 AIML_shuifu1988的博客-CSDN博客