def digraph(): """Computes the most probable digraph starting with a given character and input text""" callback = request.query.callback text_link = request.query.txt start = request.query.start print "/digraph with callback=" + callback + " text_link=" + text_link + " start=" + start response.set_header("Access-Control-Allow-Origin", "*") yield callback text = urlopen(text_link).read() char_analysis = analyze_text(text, 2, True) digraph = compute_most_probable_digraph(char_analysis, start) yield "( 'digraph': " + digraph + ")" return
def so(): """Fetches text from provided link, analyzes text (second-order) and returns results as JSONP""" callback = request.query.callback text_link = request.query.txt skip = (request.query.skip == "True") print "/so with callback=" + callback + " text_link=" + text_link + " skip= " + str(skip) response.set_header("Access-Control-Allow-Origin", "*") yield callback text = urlopen(text_link).read() char_analysis = analyze_text(text, 2, skip) yield "(" + dumps(char_analysis) + ")" return