基于已有模型的情感分析系统
代码连接 https://github.com/gitstliu/SentimentAnalysis
- 基于word2vec算法
- 使用外卖评价数据和酒店评价数据训练出来的情感分析模型
- 使用前需要对语言先分词,分词结果作为系统的输入参数,简单研发即可实现服务接口.
- 如果本身有分好词的数据集也可以联系作者帮忙训练对应的模型.
创建一个WEB服务
# encoding: utf-8
from flask import Flask, request, jsonify
import json
import SentimentAnalysis.predict.predict as predict
app = Flask(__name__)
predictmodel = predict.createpredict("SentimentAnalysis/models/svm.pickle", "SentimentAnalysis/models/svm.chisquare")
@app.route("/", methods=("POST",))
def index():
data = json.loads(request.data)
results = []
for words in data['words']:
if predict.predict(predictmodel, words) == 1:
result = "正面"
else:
result = "负面"
results.append(result)
return jsonify({'results': results})
if __name__ == '__main__':
app.run(host='0.0.0.0',debug=False, port=10000)
如有任何问题请发邮件至[email protected]或留言