Skip to main content

A Japanese inflection converter.

Project description

Jinf: Japanese Inflection Converter

Jinf is a Japanese inflection converter. Jinf depends on JumanDic and follows the grammar.

Usage

pyknp integration

pyknp is the official Python binding for Jumanpp. Instances of the Morpheme class can be used as input for Jinf.

from jinf import Jinf
from pyknp import Morpheme

jinf = Jinf()

mrph = Morpheme('走る はしる 走る 動詞 2 * 0 子音動詞ラ行 10 基本形 2 "代表表記:走る/はしる"')

print(mrph.midasi)          # 走る
print(mrph.genkei)          # 走る

print(jinf(mrph, "基本形"))  # 走る
print(jinf(mrph, "未然形"))  # 走ら
print(jinf(mrph, "意志形"))  # 走ろう
print(jinf(mrph, "命令形"))  # 走れ

mrph = Morpheme('言語 げんご 言語 名詞 6 普通名詞 1 * 0 * 0 "代表表記:言語/げんご カテゴリ:抽象物"')
print(jinf(mrph, "基本形"))  # ValueError: '言語' is invariable

mrph = Morpheme('走る はしる 走る 動詞 2 * 0 子音動詞ラ行 10 基本形 2 "代表表記:走る/はしる"')
print(jinf(mrph, "三角形"))  # ValueError: '三角形' is not a valid inflection form

mrph = Morpheme('走る はしる 走る 動詞 2 * 0 子音動詞ラ行 10 基本形 2 "代表表記:走る/はしる"')
print(jinf(mrph, "三角形"))  # ValueError: '三角形' is not a valid inflection form

mrph = Morpheme('走る はしる 走る 動詞 2 * 0 子音動詞ラ行 10 基本形 2 "代表表記:走る/はしる"')
print(jinf(mrph, "デアル列命令形"))  # ValueError: 'デアル列命令形' is not a valid inflection form for '走る'

Manual

Jinf also can be used by manually providing linguistic information.

from jinf import Jinf

jinf = Jinf()

lemma = "走る"            # corresponds to `mrph.genkei` in pyknp
inf_type = "子音動詞ラ行"  # corresponds to `mrph.katuyou1` in pyknp

print(jinf.convert(lemma, inf_type, "基本形"))  # 走る
print(jinf.convert(lemma, inf_type, "未然形"))  # 走ら
print(jinf.convert(lemma, inf_type, "意志形"))  # 走ろう
print(jinf.convert(lemma, inf_type, "命令形"))  # 走れ

List of 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

jinf-0.1.0.tar.gz (7.2 kB view hashes)

Uploaded Source

Built Distribution

jinf-0.1.0-py3-none-any.whl (7.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page