pyaiml不对< that>标签 [英] pyaiml does not respond on <that> tag

查看:80
本文介绍了pyaiml不对< that>标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PyAiml软件包编写聊天机器人。我写了一个非常基本的程序,其中包含了A.L.I.C.E.所有这些默认的aiml文件。到目前为止,除了< that>标签。我认为这是会议的问题。然后,我固定了会议。但是< that>仍然没有运气用于上下文对话的标签。任何人都知道如何使其工作吗?或者PyAiml的< that>有一些错误。标签解析?

I am trying the PyAiml package to write a chatbot. I wrote a very basic program with all those default aiml files from A.L.I.C.E. Everything works fine so far except the <that> tag. I thought it was the session problem. Then I fixed the session. But still no luck with <that> tag for contextual conversation. Anyone knows how to make it work? Or the PyAiml has some bug with <that> tag parsing?

这是我的机器人程序,也是我正在测试的一个非常小的目标文件:

Here is my bot program and a very minimal aiml file I am testing with:

testbot .py

import aiml
import marshal
import os
from pprint import pprint

BOOTSTRAP_FILE = "/var/www/html/chatbot/std-startup.xml"
BOT_SESSION_PATH = "/var/www/html/chatbot/"

sess_id = 'user_id_moshfiqur'

while True:
    k = aiml.Kernel()
    k.bootstrap(learnFiles=BOOTSTRAP_FILE, commands="load aiml b")

    if os.path.isfile(BOT_SESSION_PATH + sess_id + ".ses"):
        sessionFile = file(BOT_SESSION_PATH + sess_id + ".ses", "rb")
        sessionData = marshal.load(sessionFile)
        sessionFile.close()

        for pred, value in sessionData.items():
            k.setPredicate(pred, value, sess_id)

    response = k.respond(raw_input(">> "), sessionID=sess_id)

    sessionData = k.getSessionData(sess_id)
    pprint(sessionData)
    sessionFile = file(BOT_SESSION_PATH + sess_id + ".ses", "wb")
    marshal.dump(sessionData, sessionFile)
    sessionFile.close()

    pprint("<< " + response)

minimal.aiml

<aiml version="1.0.1" encoding="UTF-8">
    <category>
        <pattern>TEST1</pattern>
        <template>testing one</template>
    </category>
    <category>
        <pattern>TEST2</pattern>
        <that>testing one</that>
        <template>Success</template>
    </category>
</aiml>


推荐答案

好的,所以这花了我一段时间才能弄清楚。Pyaiml的问题是为了考虑 that 标签,您只需要在 that 标签内使用大写字母,而不能使用其他任何符号,例如'?','(',')'等等

Okay so this took me a while to figure out. The problem with Pyaiml is that for considering the that tag you'll have to use ONLY capital letters inside the that tag without any other symbols like '?','(',')' etc.

这篇关于pyaiml不对&lt; that&gt;标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆