1、python3安装pip install pip install python-aiml
2、将alice文件复制到工作区
3、源码如下:
import aiml
# Create the kernel and learn AIML files
kernel = aiml.Kernel()
kernel.learn("std-startup.xml")
kernel.respond("load aiml b")
# Press CTRL-C to break this loop
while True:
print(kernel.respond(input("Enter your message >> ")))
std-startup.xml
<aiml version="1.0.1" encoding="UTF-8">
<!-- std-startup.xml -->
<!-- Category is an atomic AIML unit -->