ainconv - Ainu language script converter
Overview
This cargo crate 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. The default Katakana output uses the broadly adopted modern forms, and optional Katakana variant flags are available for compact historical or small-kana forms.
Sentence-style input is supported by converting Ainu words while preserving surrounding non-Ainu text and punctuation. Latin input is normalized to lower case during conversion.
Important Note
Conversion between Latin and Cyrillic script are lossless, however, conversion between Katakana and 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 Katakana script used broadly for the Ainu language is intrinsically ambiguous. For example, it does not distinguish between tow and tu (both トゥ), iw and i.u (both イウ), ay and a.i (both アイ), etc. Some alternative Katakana scripts are proposed to solve this problem, but none of them are widely adopted. We are planning to support some of these alternative scripts in the future.
For a full survey of Ainu orthographic variation and how each issue maps to converter behaviour, see the shared orthographic variation catalogue in ainconv-tests (cross-implementation; maps to its options.schema.json).
Installation
Install the package using cargo
or add the following line to your Cargo.toml file
[]
= "0.3.0"
Usage
Word Conversion
use
println!; // "irankarapte"
println!; // "イランカラㇷ゚テ"
println!; // "irankarapte"
println!; // "иранкараптэ"
println!; // "イランカラㇷ゚テ"
println!; // "иранкараптэ"
Katakana Variants
convert_latn_to_kana keeps the default modern spelling, such as ウィ, ウェ, ウォ, イ, ウ, and ン.
Use KanaOptions with convert_latn_to_kana_with_options or convert_cyrl_to_kana_with_options when you need compact Katakana variants.
use ;
let opts = KanaOptions ;
println!; // "ヰキ"
println!; // "ヱンㇰㇽ"
println!; // "アイㇴ"
Each KanaOptions field defaults to false, so you can opt into only the variants you need:
| field | keeps | default output |
|---|---|---|
use_wi |
ヰ |
ウィ |
use_we |
ヱ |
ウェ |
use_wo |
ヲ |
ウォ |
use_small_i |
ィ for -y coda |
イ |
use_small_u |
ゥ for -w coda |
ウ |
use_small_n |
ㇴ for -n coda |
ン |
Extra Functionality
Script Detection
Detect the script of a given string.
use detect;
println!; // "Latn"
println!; // "Kana"
println!; // "Cyrl"
Syllable Splitting
use separate;
println!; // ["e", "yay", "ko", "si", "ram", "suy", "pa"]
License
MIT License (c) 2024 mkpoli
See also
- ainconv - npm: The JavaScript version of this package
- ainconv - PyPI: The Python version of this package
- Module:ain-kana-conv - ウィクショナリー日本語版: The original Lua Scribunto module in the Japanese Wiktionary