語義理解
貌似此接口已經下線,調用無正確返回值。
$officialAccount->semantic->query(string $keyword, string $categories, array $optional = []);
參數說明:
-
string $keyword
為關鍵字 -
string $categories
需要使用的服務類型,多個用 “,” 隔開字符串,不能為空 - `$optional 為其它屬性:
-
float latitude
緯度坐標,與經度同時傳入;與城市二選一傳入 -
float longitude
經度坐標,與緯度同時傳入;與城市二選一傳入 -
string city
城市名稱,與經緯度二選一傳入 -
stringregion
區域名稱,在城市存在的情況下可省;與經緯度二選一傳入 -
string uid
用戶唯一id
(非開發者id
),用戶區分公眾號下的不同用戶(建議填入用戶openid
),如果為空,則無法使用上下文理解功能。appid
和uid
同時存在的情況下,才可以使用上下文理解功能。
-
注:單類別意圖比較明確,識別的覆蓋率比較大,所以如果只要使用特定某個類別,建議將
category
只設置為該類別。
使用示例:
<?php
$result = $officialAccount->semantic->query('查一下明天從北京到上海的南航機票', "flight,hotel", array(
'city' => '北京',
'uid' => '123456'
));
// 查詢參數:
/*
{
"query": "查一下明天從北京到上海的南航機票",
"city": "北京",
"category": "flight,hotel",
"appid": "wxaaaaaaaaaaaaaaaa",
"uid": "123456"
}
*/
返回值示例:
{
"errcode": 0,
"query": "查一下明天從北京到上海的南航機票",
"type": "flight",
"semantic": {
"details": {
"start_loc": {
"type": "LOC_CITY",
"city": "北京市",
"city_simple": "北京",
"loc_ori": "北京"
},
"end_loc": {
"type": "LOC_CITY",
"city": "上海市",
"city_simple": "上海",
"loc_ori": "上海"
},
"start_date": {
"type": "DT_ORI",
"date": "2014-03-05",
"date_ori": "明天"
},
"airline": "中國南方航空公司"
},
"intent": "SEARCH"
}
}