示例#1
0
def emotion():
    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.emotion_analysis(raw, twit)
            if ret is None:
                return jsonift(error="Can't do emotion analysis!")
            return jsonify(results=ret)
    else:
        return render_template("emotion.html")
示例#2
0
def emotion():
    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.emotion_analysis(raw,twit)
            if ret is None:
                return jsonift(error="Can't do emotion analysis!")
            return jsonify(results=ret)
    else:
        return render_template('emotion.html')
示例#3
0
def analyze_emotion(filename):
    with open(filename, 'rU') as f:
        return {filename:dict(nlp.emotion_analysis(f.read()))}
示例#4
0
        data = pd.read_csv(uploaded_file)
        st.write(data)
        if st.button('开始挖掘热点'):
            '聚类中请稍后...'
            df = getHot(data, 0.6, 10)
            # Add a placeholder
            st.write('聚类完成!')
            st.write(df)

if option == '情感倾向分析':
    st.title('情感分析系统')
    st.markdown('Affective tendency analysis system')
    text = st.text_area('请输入要分析的文本')
    if st.button('开始分析'):
        st.write('分析结果为')  #展示一个感情置信度
        a, b, c, d = emotion_analysis(text)
        chart_data = pd.DataFrame([[c, d]],
                                  columns=['positive_prob', 'negative_prob'])
        st.bar_chart(chart_data)
        if a == 2:
            st.write('正向感情')
            st.write('分类置信度为:', b)
        elif a == 1:
            st.write('中性感情')
            st.write('分类置信度为:', b)
        else:
            st.write('负向感情')
            st.write('分类置信度为:', b)

if option == '评论观点抽取':
    st.title('观点抽取系统')