Code Monkey home page Code Monkey logo

ja_itaiji-py's Introduction

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.

ja_itaiji-py's People

Contributors

rjchiba avatar

Watchers

 avatar

ja_itaiji-py's Issues

正字体への変換

  • 入力文字列に含まれる異体字を正字体に整形して出力
  • 入力文字列に異体字が含まれているか判断

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.