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")
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')
def polarity(filename): with open(filename, 'rU') as f: return {filename: nlp.polarity_dist(f.read())}