Jinf is a Japanese inflection converter. Jinf depends on JumanDic and follows the grammar.
pip install jinf
from jinf import Jinf
jinf = Jinf()
text = "走る"
inf_type = "子音動詞ラ行"
source_inf_form = "基本形"
print(jinf(text, inf_type, source_inf_form, "基本形")) # 走る
print(jinf(text, inf_type, source_inf_form, "未然形")) # 走ら
print(jinf(text, inf_type, source_inf_form, "意志形")) # 走ろう
print(jinf(text, inf_type, source_inf_form, "命令形")) # 走れ
print(jinf(text, inf_type, source_inf_form, "三角形")) # ValueError: '三角形' is not a valid inflection form of '子音動詞ラ行'
print(jinf(text, inf_type, source_inf_form, "デアル列命令形")) # ValueError: 'デアル列命令形' is not a valid inflection form of '子音動詞ラ行'
pyknp integration
pyknp is the official Python binding for Jumanpp. To enable the pyknp integration, specify the extra requirement when installing Jinf:
pip install jinf[pyknp]
Morpheme objects can be used as input for Jinf as follows.
from jinf import Jinf
from pyknp import Morpheme
jinf = Jinf()
mrph = Morpheme('走る はしる 走る 動詞 2 * 0 子音動詞ラ行 10 基本形 2 "代表表記:走る/はしる"')
print(jinf.convert_pyknp_morpheme(mrph, "基本形")) # 走る
print(jinf.convert_pyknp_morpheme(mrph, "未然形")) # 走ら
print(jinf.convert_pyknp_morpheme(mrph, "意志形")) # 走ろう
print(jinf.convert_pyknp_morpheme(mrph, "命令形")) # 走れ
print(jinf.convert_pyknp_morpheme(mrph, "三角形")) # ValueError: '三角形' is not a valid inflection form of '子音動詞ラ行'
print(jinf.convert_pyknp_morpheme(mrph, "デアル列命令形")) # ValueError: 'デアル列命令形' is not a valid inflection form of '子音動詞ラ行'
See JUMAN.katuyou in JumanDic.