A minimalistic Python morphological analyzing / inflection (RU & UK) microservice based on pymorphy2
git clone https://github.com/k0rean-rand0m/grammar-unit.git
pip install pymorphy2 flask waitress
env FLASK_APP=app.py flask run
python app.py
docker pull docker.pkg.github.com/k0rean-rand0m/grammar-unit/grammar-unit:latest
docker run -p 5000:5000 -d docker.pkg.github.com/k0rean-rand0m/grammar-unit/grammar-unit:latest
Get response via GET request to the api with params:
- word required - the word for a morphology analysis / mutation
- in_case - change case to a given
- in_number - change number to a given
- num_agree - turns the word in the form which is agree with a number (can be mixed with in_case)
Requesting with word parameter only will lead to a response with full morphology analysis of the given word. Providing the request with in_case or/and in_number will resolve into a response with a mutated word.
in_case | in_number | num_agree |
---|---|---|
nomn | sing | any_number |
gent | plur | |
datv | ||
accs | ||
ablt | ||
loct |
http://localhost:5000/?word=сингулярность
{
"code": 200,
"message": [{
"normal_form": "сингулярность",
"part_of_speech": "NOUN",
"case": "nomn",
"gender": "femn",
"number": "sing",
"tense": null,
"score": 0.5
}, {
"normal_form": "сингулярность",
"part_of_speech": "NOUN",
"case": "accs",
"gender": "femn",
"number": "sing",
"tense": null,
"score": 0.5
}]
}
http://localhost:5000/?word=сингулярность&in_case=gent
{
"code": 200,
"message": "сингулярности"
}