Add application file
Browse files- Dockerfile +9 -0
- app.py +26 -0
- requirements.txt +8 -0
Dockerfile
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM ubuntu
|
2 |
+
RUN apt-get update -y && \
|
3 |
+
apt-get install -y python3 python3-pip git
|
4 |
+
WORKDIR /app
|
5 |
+
COPY . /app
|
6 |
+
RUN pip install --upgrade pip
|
7 |
+
RUN pip install -r requirements.txt
|
8 |
+
EXPOSE 4000
|
9 |
+
CMD ["sh", "-c", "python3 -m spacy download en && python3 ./app.py"]
|
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, request, jsonify
|
2 |
+
from flask_cors import CORS
|
3 |
+
from gramformer import Gramformer
|
4 |
+
from autocorrect import Speller
|
5 |
+
|
6 |
+
app = Flask(__name__)
|
7 |
+
CORS(app)
|
8 |
+
|
9 |
+
def process(text):
|
10 |
+
gf = Gramformer(models=1, use_gpu=False)
|
11 |
+
spell = Speller()
|
12 |
+
corrected = spell(text)
|
13 |
+
ans = ""
|
14 |
+
res = gf.correct(corrected)
|
15 |
+
for ele in res:
|
16 |
+
ans += ele
|
17 |
+
return ans
|
18 |
+
|
19 |
+
@app.route('/', methods=["POST"])
|
20 |
+
def post():
|
21 |
+
data = request.get_json()
|
22 |
+
res = process(data["text"])
|
23 |
+
return res
|
24 |
+
|
25 |
+
if __name__ == '__main__':
|
26 |
+
app.run(host="0.0.0.0", port=4000)
|
requirements.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
requests
|
2 |
+
Flask
|
3 |
+
Flask-Cors
|
4 |
+
torch
|
5 |
+
transformers
|
6 |
+
git+https://github.com/PrithivirajDamodaran/Gramformer.git
|
7 |
+
autocorrect
|
8 |
+
spacy
|