我正在从事一个用于休闲的 AIML 项目,并遇到了潘多拉机器人。我想知道是否有办法将用户输入中的变量解析为其他语言(在本例中为 python)或框架,以便我们可以通过任何模板通过其他第三方 API 进行进一步操作?
例如,我想从用户那里获取日期,然后将其输入谷歌日历 API。有没有办法提取“日期”变量并将其解析为 Python(或任何其他语言)中的谷歌日历 API?
<category><pattern># 1 MAY 2016 #</pattern>
<think>{{ date }}</think> #is there a way to parse "1 May 2016" as a
#variable date in python?
<template>...
</template>
</category>
最终,我试图实现的目标将是这样的对话:
User: Hi bot, could you check if I am available on 1 May 2016?
Bot: Nope, you have a gathering at Mike's! #(<--- Response rendered after
checking user's schedule on 1 May via google calendar )
我探索了像 mustache 这样的模板引擎,但显然它不与 AIML(或者更确切地说是 xml)对话。有没有人可以为我指出一个可以帮助我入门的好例子/教程?
ps:我正在使用pandorabots API和python2.7