Skip to content

Commit

Permalink
support different corrector
Browse files Browse the repository at this point in the history
  • Loading branch information
david ullua committed Sep 4, 2022
1 parent 8d5b921 commit 4c76b40
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions flask_server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pycorrector.macbert.macbert_corrector import MacBertCorrector
from pycorrector import config
import pycorrector
from flask import Flask, request, jsonify
from loguru import logger
import json
Expand All @@ -20,6 +21,23 @@ def hello_world():

correct = MacBertCorrector(config.macbert_model_dir).macbert_correct

@app.route('/pyc', methods=['POST','GET'])
def py_correct():
if request.method == 'POST':
data = request.json
logger.info("Received data: {}".format(data))
text = data["text"]
corrected_sent, detail = pycorrector.correct('少先队员因该为老人让坐')
return corrected_sent + " " + str(detail)
else:
if "text" in request.args:
text = request.args.get("text")
logger.info("Received data: {}".format(text))
corrected_sent, detail = pycorrector.correct('少先队员因该为老人让坐')
return corrected_sent + " " + str(detail)
return help


@app.route('/c', methods=['POST','GET'])
def correct_api():
if request.method == 'POST':
Expand Down

0 comments on commit 4c76b40

Please sign in to comment.