2017-07-15 24 views
3

建於像「智慧$位置」的實體我一直在使用API​​服務嘗試:如何添加值在wit.ai

response = requests.post('https://api.wit.ai/entities/wit$location/values?v=20160526', 
         headers={'Authorization':'Bearer xxx'}, 
         data=json.dumps({ "value":"London", 
              "expressions":["London"], 
              "metadata":"CITY_1234"})) 

但我得到的迴應是:

{'code': 'not-found', 
'error': "Entity '535a80ff-6399-4653-8b2a-c770dd014965' not found"} 

我我很確定存在名爲wit$location的實體。

response = requests.get('https://api.wit.ai/entities/wit$location?v=20160526', 
         headers={'Authorization':'Bearer xxx'}) 

和響應是:

{'builtin': True, 
'doc': '{"spanless":false,"short_desc":"specific position or ' 
     'address","long_desc":"Capture free text that\'s a typical location, ' 
     'place or address like `350 Cambridge Ave Palo Alto`, `925 Alma ' 
     'Street`, `SFO`, and `Sausalito, CA`.\\nUse wit/local_search_query for ' 
     'local place like `my flower shopt` and ' 
     '`Peet\'s`","examples":[{"expression":["meet me at","350 Cambridge Ave ' 
     'Palo Alto","at noon"],"response":"\\"entities\\" : {\\n  ' 
     '\\"location\\" : [ {\\n  \\"value\\" : \\"350 Cambridge Ave ' 
     'Palo Alto\\"\\n  } ]\\n ' 
     '}","$$hashKey":"070"},{"expression":["go to","925 Alma ' 
     'street",""],"response":"\\"entities\\" : {\\n  \\"location\\" : [ ' 
     '{\\n  \\"value\\" : \\"925 Alma street\\"\\n  } ]\\n ' 
     '}","$$hashKey":"07Z"},{"expression":["i need a ride to","Sausalito, ' 
     'CA",""],"response":"\\"entities\\" : {\\n  \\"location\\" : [ ' 
     '{\\n  \\"value\\" : \\"Sausalito, CA\\"\\n  } ]\\n ' 
     '}","$$hashKey":"081"},{"expression":["I came ' 
     'from","SFO","?"],"response":"\\"entities\\" : {\\n  ' 
     '\\"location\\" : [ {\\n  \\"value\\" : \\"SFO\\"\\n  } ' 
     ']\\n ' 
     '}","$$hashKey":"083"}],"similar_wisps":[{"name":"wit/local_search_query","$$hashKey":"072"}]}', 
'exotic': False, 
'id': '535a80ff-6399-4653-8b2a-c770dd014965', 
'lang': 'en', 
'lookups': ['free-text'], 
'name': 'location', 
'values': []} 

我希望能夠將值添加到wit$location實體。

回答

0

據我所知,你不能編輯/添加到內置的實體。原因在於,也許你想在星球大戰中或者在你的晦澀地區添加所有城市,但其他人不希望讓它們彈出。

我的工作是添加一個名爲「my_city」的實體,並將您特別想識別的城市添加到該實體。在您的代碼中,您只需在檢查位置時檢查兩個實體中的一個...

希望這有助於您,祝您好運!

+0

我希望能夠加入像「我在巴黎新」到實體「智慧$位置」沒有GUI的幫助文本和receieve像一個API響應: ''' [ { 「信心 「:空, 」意圖「: 」default_intent「, 」_text「: 」我在巴黎新「, 」實體「:{ 」位置「: { 」建議「:真實, 」信心「:0.99637981156554, 」value「:」Paris「, 」type「:」value「 } ] } } ] ''' –