Example #1
0
def polarity():
    if request.method == "POST":
        if "option" not in request.form:
            return jsonify(error="must select an option for the NLP function!")
        raw, twit = request.form["raw"], False
        if request.form["option"] == "twitter":
            twit = True
        if len(raw) != 0:
            ret = nlp.polarity_dist(raw, twit)
            if ret is None:
                return jsonift(error="Can't do analyze polarity distribution!")
            return jsonify(results=ret)
    else:
        return render_template("polarity.html")
Example #2
0
def polarity():
    if request.method == 'POST':
        if 'option' not in request.form:
            return jsonify(error="must select an option for the NLP function!")
        raw, twit = request.form['raw'], False
        if request.form['option'] == 'twitter':
            twit=True
        if len(raw) !=0:
            ret = nlp.polarity_dist(raw, twit)
            if ret is None:
                return jsonift(error="Can't do analyze polarity distribution!")
            return jsonify(results=ret)
    else:
        return render_template('polarity.html')
Example #3
0
def polarity(filename):
    with open(filename, 'rU') as f:
        return {filename: nlp.polarity_dist(f.read())}