File size: 573 Bytes
f7e9ec5 |
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 |
from flask import Flask, request, jsonify
from flask_cors import CORS
from gramformer import Gramformer
from autocorrect import Speller
app = Flask(__name__)
CORS(app)
def process(text):
gf = Gramformer(models=1, use_gpu=False)
spell = Speller()
corrected = spell(text)
ans = ""
res = gf.correct(corrected)
for ele in res:
ans += ele
return ans
@app.route('/', methods=["POST"])
def post():
data = request.get_json()
res = process(data["text"])
return res
if __name__ == '__main__':
app.run(host="0.0.0.0", port=4000) |