A Japanese inflection converter.
Project description
Jinf: Japanese Inflection Converter
Jinf is a Japanese inflection converter. Jinf depends on JumanDic and follows the grammar.
Installation
pip install jinf
Usage
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
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
print(jinf.convert_pyknp_morpheme(mrph, "デアル列命令形")) # ValueError: 'デアル列命令形' is not a valid inflection form of '子音動詞ラ行'
List of available inflection types/forms
Run the following:
from jinf import INFLECTION_TYPES, INFLECTION_FORMS
print(INFLECTION_TYPES) # ["母音動詞", "子音動詞カ行", "子音動詞カ行促音便形", ...]
print(INFLECTION_FORMS) # ["語幹", "基本形", "未然形", ...]
See JUMAN.katuyou in JumanDic for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jinf-1.0.0.tar.gz
(7.3 kB
view hashes)
Built Distribution
jinf-1.0.0-py3-none-any.whl
(7.0 kB
view hashes)