python模拟机器人对话,全匹配

1、python3安装pip install pip install python-aiml

2、将alice文件复制到工作区

python模拟机器人对话,全匹配_第1张图片
python模拟机器人对话,全匹配_第2张图片

3、源码如下:

testb.py


    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


    
    

    
    

        
        
        LOAD AIML B

        
        
        
        
    



basic_chat.aiml


    


    
        HELLO
        
    
    
    
        WHAT ARE YOU
        
    

    
        你好
        
    

    
        2
        
    
    



运行结果:
python模拟机器人对话,全匹配_第3张图片

你可能感兴趣的:(python模拟机器人对话,全匹配)