Skip to main content

ja-itaiji: handling Japanese 異体字 (itaiji), which are variant forms of kanji characters

Project description

ja-itaiji

ja-itaiji is a Python package for handling Japanese 異体字 (itaiji), which are variant forms of kanji characters. This package allows you to find equivalent characters, check if two kanji characters or words are equivalent, and generate a list of similar words by replacing kanji with their itaiji.

Features

  • Get Itaiji Family: Retrieve a list of kanji characters that are equivalent to a given kanji.
  • Check Kanji Equivalence: Determine whether two kanji characters are equivalent itaiji.
  • Check Word Equivalence: Check if two words are equivalent within itaiji.
  • Generate Similar Words: Generate a list of words by replacing each kanji with its equivalent itaiji.

Installation

To install the package, use pip:

pip install ja-itaiji

Usage

Importing the Package

from ja_itaiji import Itaiji

Get Itaiji Family

Retrieve a list of kanji characters that are equivalent to a given kanji.

family = Itaiji.get_family('漢')
print(family)  # Output: ['漢', '㵄', '漢', '汉']

Check Kanji Equivalence

Determine whether two kanji characters are equivalent itaiji.

is_equivalent = Itaiji.is_family('漢', '㵄')
print(is_equivalent)  # Output: True

Check Word Equivalence

Check if two words are equivalent within itaiji.

is_similar = Itaiji.is_similar('漢字', '汉字')
print(is_similar)  # Output: True

Generate Similar Words

Generate a list of words by replacing each kanji with its equivalent itaiji.

similar_words = Itaiji.get_similar('漢字')
print(similar_words)  # Output: ['漢字', '㵄字', '漢字', '汉字']

You can also specify the number of replacing.

similar_words = Itaiji.get_similar("低頭思故郷", n=1)
print(similar_words)  # Output: ['低頭思故郷', '低頭思故鄕', '低頭思故乡', '低頭楒故郷', '低頭䰄故郷', '低頭恖故郷', '低头思故郷', '氐頭思故郷', '仾頭思故郷']

Data

The package uses a JSON file (ja-itaiji.json) that contains mappings of kanji to their itaiji. Ensure that this file is located in the correct directory as specified by ITAIJI_PATH.

License

This project is licensed under the MIT License. See the LICENSE file 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

ja_itaiji-1.0.1.tar.gz (171.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ja_itaiji-1.0.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file ja_itaiji-1.0.1.tar.gz.

File metadata

  • Download URL: ja_itaiji-1.0.1.tar.gz
  • Upload date:
  • Size: 171.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for ja_itaiji-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3d275a2883cb228331d2c285864b513294c7eb5c43ac5c54e049460870ce03ec
MD5 51f4949d870860ef3e1d9a31feeed3c8
BLAKE2b-256 37aa5de839e8877500814d741ffe5c5dd1095d6d81fd6018d985d0c2dfcd8b3e

See more details on using hashes here.

File details

Details for the file ja_itaiji-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ja_itaiji-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for ja_itaiji-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7c50cac7de44636da70e9cf1913be08946ad922ebe80c4c13e7c324a2dad2072
MD5 01368a4dd44c2f36d013a97a525eb441
BLAKE2b-256 9314f53d18695c868e43a44e1ca1ee49f678e37ed19a25fd0bb3e62d1ffb508c

See more details on using hashes here.

Supported by

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