[英]From python to AIML
我正在嘗試創建我想要用於家庭自動化項目的第一個聊天機器人。
這可能聽起來很愚蠢,也許這不是要走的路,但我希望得到你的意見,也許還有辦法讓它發揮作用。
我希望能夠問我的機器人我的位置是什么,我希望它運行我的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
現在我不知道怎么把它變成我的aiml文件。
<?xml version="1.0" encoding="UTF-8"?>
<aiml>
<category>
<pattern>WHAT IS MY LOCATION</pattern>
<template>??????</template>
</category>
</aiml>
我希望這有點道理:)
謝謝您的幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.