Skip to main content

$nlp.inflect

Declines a Russian word into the required case.

Declination is performed using pymorphy2. Declinations are set in its format.

How to use

In the example below, gent is the genitive case.

require: city/city.sc
module = sys.zb-common

theme: /

state: WhatCityAreYouFrom
# What city are you from?
a: Из какого вы города?

state: GetCity
q: * $City *
if: $parseTree._City.name === "Санкт-Петербург" # St. Petersburg
# Wow, I’m from St. Petersburg, too!
a: Ух ты, я тоже из Питера!
else:
# # You’re from $parseTree._City.name, great! And I’m from St. Petersburg.
a: Из {{capitalize($nlp.inflect($parseTree._City.name, "gent"))}}, здорово! А я из Питера.