#NEWLINE# def process_query( input ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# r = requests . get ( ( 'https://api.wit.ai/message?v=20160420&q=' + input ) , headers = { #NEWLINE# #INDENT# 'Authorization' : ( 'Bearer %s' % WIT_AI_ACCESS_TOKEN ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# data = r . json ( ) #NEWLINE# intent = data [ 'outcomes' ] [ 0 ] [ 'intent' ] #NEWLINE# entities = data [ 'outcomes' ] [ 0 ] [ 'entities' ] #NEWLINE# confidence = data [ 'outcomes' ] [ 0 ] [ 'confidence' ] #NEWLINE# if ( ( intent in src . __all__ ) and ( confidence > 0.5 ) ) : #NEWLINE# #INDENT# return ( intent , entities ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( None , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# return ( None , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } )