Skip to content

slowprog/pymorphy-api

Repository files navigation

Pymorphy API

Declination in the cases of Russian phrases.

The service uses the pymorphy2 library, which uses OpenCorpora dictionaries.

The service is based on the yiivgeny/pymorphy2 (build the latest available dictionaries) and summerisgone/pyphrasy. The service use Django and Docker.

Usage

For development:

$ docker-compose up -d

For production:

$ docker-compose -f ./docker-compose.prod.yml up -d
# or
$ docker run -d --name pymorphy_api -p 8000:8000 -e ALLOWED_HOSTS=localhost slowprog/pymorphy-api

The service is waiting for a request with two parameters:

  1. phrase – what to decline.
  2. forms – one element or list of cases and / or noun-number from pymorphy2, separated by commas.

Example: http://localhost:8000/api/inflect?phrase=неожиданный%20дедлайн&forms=gent,plur&forms=loct

The response is in json format, which will contain an option for each of the forms:

{
    "success": true,
    "data": {
        "gent,plur": "неожиданных дедлайнов",
        "loct": "неожиданном дедлайне"
    }
}

In case of an error, the key date will contain the text of the error:

{
    "success": false,
    "data": "The phrase parameter is not specified."
}

About

Russian declension with pymorphy2

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •