def analyse_textrank():
text = request.values.get('text', "text")
topK = request.values.get("topK", default="20")
if topK in [str(x) for x in range(3,41)]:
topK = int(topK)
else:
topK = 20
withWeight = request.values.get("withWeight", default="0")
if withWeight in ['0', '1']:
withWeight = bool(int(withWeight))
else:
withWeight = True
result = list(jieba.analyse.textrank(text, topK=topK, withWeight=withWeight))
return jsonify(text=text, topK=topK, withWeight=withWeight, result=result)
评论列表
文章目录