我正在尝试创建我想要用于我的家庭自动化项目的第一个聊天机器人。
这听起来可能很愚蠢,也许这不是一条路可走,但我想听听你的意见,也许是一种让它发挥作用的方法。
我希望能够问我的机器人我的位置是什么,我希望它运行我的python代码,返回我的当前位置,然后得到答案。
这是我的location.py
from pyicloud import PyiCloudService
import googlemaps
import aiml
api_key = "##################3"
gmaps = googlemaps.Client(key= api_key)
api = PyiCloudService('###email####','###password###')
longitude = api.iphone.location()['longitude']
latitude = api.iphone.location()['latitude']
current_location = gmaps.reverse_geocode((latitude, longitude))
street = current_location[0]['address_components'][1]['long_name']
house_number = current_location[0]['address_components'][0]['long_name']
def get_location():
current_location = ('%s,%s' % (street, house_number))
return current_location现在我不知道怎么把这个放进我的文件里了。
<?xml version="1.0" encoding="UTF-8"?>
<aiml>
<category>
<pattern>WHAT IS MY LOCATION</pattern>
<template>??????</template>
</category>
</aiml>我希望这是有意义的:)
谢谢你的帮助!
发布于 2016-07-22 22:57:06
如果您的位置是芝加哥,您可以在Python中使用kernel.setPredicate("location", "Chicago"),然后在AIML中输出如下所示的值:
<category>
<pattern>WHAT IS MY LOCATION</pattern>
<template>Your location: <get name="location"></get></template>
</category>看看这里的例子。
https://stackoverflow.com/questions/38411748
复制相似问题