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 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 '子音動詞ラ行'
List of available inflection types/forms
See JUMAN.katuyou in JumanDic.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jinf-1.0.4.tar.gz.
File metadata
- Download URL: jinf-1.0.4.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.14 CPython/3.10.5 Darwin/21.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
749982c729a76ea73a075edb1fc9226c81f676b549497f9cb935898ae08f6495
|
|
| MD5 |
8714bd6bad8f7bf66fb1682d102eb95d
|
|
| BLAKE2b-256 |
091b810b0ba0175e0e90cda15aa020fac12330feeea60461440fea41c1147920
|
File details
Details for the file jinf-1.0.4-py3-none-any.whl.
File metadata
- Download URL: jinf-1.0.4-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.14 CPython/3.10.5 Darwin/21.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e35bef8efb476c78a2d6d9bb3c60f722cdf5f0df4d7642b19b46b8cc10f8f23f
|
|
| MD5 |
068a3ef61afcb1e85812d80d77fdf339
|
|
| BLAKE2b-256 |
c4eff8c89db1db4541139e7f72d14153265a39e33078290612399e4cbef9a45d
|