Ejemplo n.º 1
0
def suggestions():

    # Receiveing the parameters from the GET request
    queryParams = request.args.get('q')
    if queryParams == "":
        return 'null'
    # Creating a Trie object
    trie = Trie()

    # Creating a Full Trie from the corpus received
    sentences = service_data
    for sentence in sentences:
        trie.addSentence(sentence)

    # Getting the list of suggestions by supplying query
    result = trie.generate_completions(queryParams)

    return jsonify(Completions=result)