/grammar-unit

Python morphological analyzer / inflection (RU & UK) microservice based on pymorphy2

Primary LanguagePython

grammar-unit

A minimalistic Python morphological analyzing / inflection (RU & UK) microservice based on pymorphy2

Installation and running

From source

git clone https://github.com/k0rean-rand0m/grammar-unit.git
pip install pymorphy2 flask waitress

Running in dev

env FLASK_APP=app.py flask run

Running in production

python app.py

Docker

Pull the image

docker pull docker.pkg.github.com/k0rean-rand0m/grammar-unit/grammar-unit:latest

Running in production

docker run -p 5000:5000 -d docker.pkg.github.com/k0rean-rand0m/grammar-unit/grammar-unit:latest

Requesting

Params

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.

Possible values

in_case in_number num_agree
nomn sing any_number
gent plur
datv
accs
ablt
loct

Request samples

Request

http://localhost:5000/?word=сингулярность

Response

{
  "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
  }]
}

Request

http://localhost:5000/?word=сингулярность&in_case=gent

Response

{
  "code": 200,
  "message": "сингулярности"
 }