-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #304 from Shubh-Goyal-07/restructure
Updates spell_check module
- Loading branch information
Showing
14 changed files
with
397 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
quart | ||
aiohttp | ||
python-Levenshtein | ||
requests | ||
requests | ||
symspellpy |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Use an official Python runtime as a parent image | ||
FROM python:3.9-slim | ||
|
||
WORKDIR /app | ||
|
||
# Install system packages required for building kenlm | ||
RUN apt-get update && apt-get install -y cmake g++ zlib1g-dev | ||
|
||
# Install requirements | ||
COPY requirements.txt requirements.txt | ||
RUN pip3 install -r requirements.txt | ||
|
||
# Install wget | ||
RUN apt-get update && apt-get install -y wget | ||
|
||
# Download the files using wget | ||
RUN wget "https://drive.google.com/uc?export=download&id=14cMmeDPlAODbRe37CdHLnhClGX7JXG-A" -O 'freq_dict.txt' | ||
RUN wget "https://drive.google.com/uc?export=download&id=1Ztj6k0A4BMi_o87qwSDKJQ6cyhvlvneD" -O 'freq_dict_eng.txt' | ||
|
||
# Copy the rest of the application code to the working directory | ||
COPY . /app/ | ||
|
||
EXPOSE 8000 | ||
|
||
# Set the entrypoint for the container | ||
CMD ["hypercorn", "--bind", "0.0.0.0:8000", "api:app"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
**curl request for inferenece:** | ||
|
||
curl -X POST -H "Content-Type: application/json" -d '{ | ||
"text": "ପାମ ମିଶନରୀ ଉପରେ କେତେ % ରିହାତି ଧୈର୍ଯ ହୋଇଛି", | ||
"lang" : "ory" | ||
}' http://localhost:8000/ | ||
|
||
curl -X POST -H "Content-Type: application/json" -d '{ | ||
"text": "ପାମ ମିଶନରୀ ଉପରେ କେତେ % ରିହାତି ଧୈର୍ଯ ହୋଇଛି" | ||
}' http://localhost:8000/ | ||
|
||
curl -X POST -H "Content-Type: application/json" -d '{ | ||
"text": "how to apply for go-sugem scheme for my paddi crop", | ||
"lang" : "eng" | ||
}' http://localhost:8000/ | ||
|
||
|
||
**curl request for update:** | ||
|
||
curl -X PUT -H "Content-Type: application/json" -d '{ | ||
"text": "ମିଶନରୀ", | ||
"lang" : "ory" | ||
}' http://localhost:8000/ | ||
|
||
curl -X PUT -H "Content-Type: application/json" -d '{ | ||
"text": ["ପାମ ମିଶନରୀ ଉପରେ", "ରିହାତି ଧୈର୍ଯ ହୋଇଛି"] | ||
}' http://localhost:8000/ | ||
|
||
curl -X PUT -H "Content-Type: application/json" -d '{ | ||
"text": "go-sugem", | ||
"lang" : "eng" | ||
}' http://localhost:8000/ | ||
|
||
curl -X PUT -H "Content-Type: application/json" -d '{ | ||
"text": ["how to apply for", "scheme for my paddi crop"], | ||
"lang" : "eng" | ||
}' http://localhost:8000/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .request import * | ||
from .model import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from model import Model | ||
from request import ModelRequest | ||
from quart import Quart, request | ||
import aiohttp | ||
|
||
app = Quart(__name__) | ||
|
||
model = None | ||
|
||
freq_dict_paths = { | ||
'ory': 'freq_dict.txt', | ||
'eng': 'freq_dict_eng.txt' | ||
} | ||
|
||
spello_model_paths = { | ||
'ory': 'spello_model.pkl', | ||
'eng': 'spello_model_eng.pkl' | ||
} | ||
|
||
|
||
@app.before_serving | ||
async def startup(): | ||
app.client = aiohttp.ClientSession() | ||
global model | ||
model = Model(app, freq_dict_paths) | ||
|
||
@app.route('/', methods=['POST']) | ||
async def infer(): | ||
global model | ||
data = await request.get_json() | ||
req = ModelRequest(**data) | ||
result = await model.inference(req) | ||
return result | ||
|
||
@app.route('/', methods=['PUT']) | ||
async def update(): | ||
# print("PUT") | ||
global model | ||
data = await request.get_json() | ||
req = ModelRequest(**data) | ||
result = await model.update(req) | ||
return result | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run() |
Oops, something went wrong.