Skip to main content

Converts Ainu text between different scripts (Katakana, Latin, Cyrillic and more)

Project description

ainconv - Ainu language script converter

Version Downloads Python Versions Read the Docs MIT License GitHub issues GitHub pull requests test Discord Aynuitak

Table of Contents

Overview

[!IMPORTANT] By default, conversions between Katakana to and from any script are inherently lossy. See Important Note for more details.

This package provides a comprehensive set of functions for converting text between different writing systems of the Ainu language.

Currently, Latin (Romanization), Katakana and Cyrillic scripts are supported. We are also planning to convert between different romanization systems and Katakana variants. Currently only the more adopted version of Latin script and lossy Katakana script are supported.

Sentence conversion is planned to be supported in the future. For now, only well-formed single word is accepted. The converted string are always in lower case.

Important Note

Conversion between Latin and Cyrillic script are lossless, however, conversion between Katakana and any other scripts are lossy. This means that converting from Katakana to other scripts and then back to Katakana may not give the original string and the result may be ambiguous or even incorrect.

This is because the most widely used Katakana orthography for the Ainu language is intrinsically ambiguous. For example, tow and tu are both トゥ, iw and i.u are both イウ, ay and a.i are both アイ, etc. Some alternative Katakana scripts are proposed to solve this problem, but none of them are widely adopted.

We already added some options (see Conversion Options) for Katakana output and are planning to support others to mitigate this problem. However, since Katakana orthography still contains less information than Latin orthography, you cannot get the original text back from the converted text, distinctions such as -w, -y and -n (with options off), = and - symbols, letter case, etc. are lost in the conversion. Additionally, Katakana text from elsewhere usually does not contain these distinctions, so converting losslessly from Katakana to other scripts is impossible.

Installation

Install the package using pip

pip install ainconv

Usage

[!NOTE] You can also read the full documentation on Read the Docs.

Word Conversion

from ainconv import (
    kana2latn,
    latn2kana,
    cyrl2latn,
    latn2cyrl,
    kana2cyrl,
    cyrl2kana,
    # ...
)

print(kana2latn("イランカラㇷ゚テ")) # "irankarapte"
print(latn2kana("irankarapte")) # "イランカラㇷ゚テ"
print(cyrl2latn("иранкараптэ")) # "irankarapte"
print(latn2cyrl("irankarapte")) # "иранкараптэ"
print(cyrl2kana("иранкараптэ")) # "イランカラㇷ゚テ"
print(kana2cyrl("イランカラㇷ゚テ")) # "иранкараптэ"

Extra Functionality

Conversion Options

Katakana
from ainconv import latn2kana

# Use ィ (-y), ゥ (-w) and ㇴ (-n)
assert latn2kana("kay") == "カイ"
assert latn2kana("kay", use_small_i=True) == "カィ"
assert latn2kana("kew") == "ケウ"
assert latn2kana("kew", use_small_u=True) == "ケゥ"
assert latn2kana("mun") == "ムン"
assert latn2kana("mun", use_small_n=True) == "ムㇴ"

# Use ヰ (wi), ヱ (we) and ヲ (wo) 
assert latn2kana("wiki") == "ウィキ"  # for loanwords only
assert latn2kana("wiki", use_wi=True) == "ヰキ"
assert latn2kana("weni") == "ウェニ"
assert latn2kana("weni", use_we=True) == "ヱニ"
assert latn2kana("wóse") == "ウォセ"
assert latn2kana("wóse", use_wo=True) == "ヲセ"

assert latn2kana("wiwewo") == "ウィウェウォ"
assert latn2kana("wiwewo", use_wi=True, use_we=True, use_wo=True) == "ヰヱヲ"

Script Detection

Detect the script of a given string.

from ainconv import detect

print(detect("aynu")) # "Latn"
print(detect("アイヌ")) # "Kana"
print(detect("айну")) # "Cyrl"

Syllable Splitting

from ainconv import separate

print(separate("eyaykosiramsuypa")) # ["e", "yay", "ko", "si", "ram", "suy", "pa"]

Support

If you have a question or have found a bug or any other issue, feel free to open an issue to let me know. For instructions on how to contribute, see CONTRIBUTING.md.

You can also join our Discord for discussion. We have many projects going on about Ainu, so you may find something interesting there as well.

License

MIT License (c) 2024 mkpoli

See also

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

ainconv-0.8.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

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

ainconv-0.8.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file ainconv-0.8.0.tar.gz.

File metadata

  • Download URL: ainconv-0.8.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for ainconv-0.8.0.tar.gz
Algorithm Hash digest
SHA256 bd29bc39ffdcf114817416056948836b9bbb110ed819953e3d662babccfcc316
MD5 0abab36df0648aceefa6ab00a7b7eae9
BLAKE2b-256 4dfaeb207eaf81d592b50574806d3fbb3ef74a8d99d2cbc2587a3ee49490c604

See more details on using hashes here.

Provenance

The following attestation bundles were made for ainconv-0.8.0.tar.gz:

Publisher: publish.yml on mkpoli/ainconv-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ainconv-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: ainconv-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for ainconv-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 74af6d29150d13aceba0e8f071b45a0065b78d95315eeffd2a9e967304014709
MD5 0f63344a0d5e016996741949d978bf00
BLAKE2b-256 3999f208f8c933d388b92dc78db4f45d7099cd87dc6be87163a878ff6a8f883e

See more details on using hashes here.

Provenance

The following attestation bundles were made for ainconv-0.8.0-py3-none-any.whl:

Publisher: publish.yml on mkpoli/ainconv-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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