Skip to content

Instantly share code, notes, and snippets.

@anacampesan
Last active November 8, 2017 17:02
Show Gist options
  • Save anacampesan/5363a22df6d0c59be7077c9d502312c9 to your computer and use it in GitHub Desktop.
Save anacampesan/5363a22df6d0c59be7077c9d502312c9 to your computer and use it in GitHub Desktop.
Wit Free Text
import json
obj = json.loads('{"msg_id":"07kg0Z1uAQMmLN6lM","_text":"i want links to racing and horses","entities":{"links_category":[{"suggested":true,"confidence":0.97013993755778,"value":"racing","type":"value"},{"suggested":true,"confidence":0.94886424860786,"value":"horses","type":"value"}]}}')
entities = obj['entities']
intents = []
for key in entities:
aux = []
for entity in entities[key]:
if entity['confidence'] > 0.6:
aux.append(entity['value'])
intents.append({
'name': key,
'values': aux
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment