File size: 928 Bytes
4c84960 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
from flask import request
from textblob import TextBlob
from flask import app
@app.route("/text/summarize", methods=["POST"])
def summarize():
text = request.json.get("text")
return {"summary": TextBlob(text).summarize()}
@app.route("/text/extract", methods=["POST"])
def extract():
text = request.json.get("text")
return {"keywords": TextBlob(text).keywords}
@app.route("/text/paraphrase", methods=["POST"])
def paraphrase():
text = request.json.get("text")
return {"paraphrase": TextBlob(text).correct()}
@app.route("/text/grammar", methods=["POST"])
def grammar():
text = request.json.get("text")
return {"errors": TextBlob(text).spellcheck()}
@app.route("/chat", methods=["POST"])
def chat():
prompt = request.json.get("prompt")
#TODO: create chatting logic
return {"response": f"prompt: {prompt}\nresponse: Still working on Text Generation logic, thanks for the patience!"}
|