def predict():
"""
API route for predicting the category of the supplied text.
The request should have type set to application/json and the provided JSON
should have a text attribute containing the text for which we want to
predict the category.
"""
try:
prediction = ct.predict(request.json['document'])
return jsonify(category=str(prediction[0]),
status=200)
except Exception as e:
return jsonify(error=True,
status=500,
message='Getting the prediction failed')
评论列表
文章目录