#NEWLINE# @ app . route ( ( ( '/v' + API_VERSION ) + '/locations' ) , methods = [ 'POST' ] ) #NEWLINE# def suggest_locations( ) : #NEWLINE# #INDENT# '\n    Suggest locations in a text string. These might be useful keywords for\n    annotators to geolocate.\n\n    input: full message\'s text [string]\n    output: dict of with outer key "locations". inner keys are entity types, with list of entities.\n\n        "locations": {\n          "GSP": [\n            "Congo"\n          ]\n        }\n\n    # [TODO]\n    # output: list. each item is a python dictionary:\n    #     - text : the text for the specific entity [string]\n    #     - indices : tuple of (start [int], end [int]) offset where entity is\n    #       located in given full message\n    #     - confidence : probability from 0-to-1 [float]\n    ' #NEWLINE# if ( ( not request . json ) and ( not ( 'text' in request . json ) ) ) : #NEWLINE# #INDENT# abort ( 400 ) #NEWLINE# #UNINDENT# entities = Machine . guess_locations ( request . json [ 'text' ] ) #NEWLINE# for ( k , v ) in entities . iteritems ( ) : #NEWLINE# #INDENT# entities [ k ] = list ( v ) #NEWLINE# #UNINDENT# return jsonify ( { #NEWLINE# #INDENT# 'locations' : entities , #NEWLINE# #UNINDENT# } )