#script #convert-text #language #text #converter #scripting-language #ainu

ainconv

Converts Ainu words between different scripts (Katakana, Latin, Cyrillic)

2 releases

0.1.1 Mar 2, 2024
0.1.0 Feb 28, 2024

#13 in #convert-text

Download history 91/week @ 2024-02-22 220/week @ 2024-02-29 24/week @ 2024-03-07 4/week @ 2024-03-14

339 downloads per month

MIT license

26KB
473 lines

ainconv - Ainu language script converter

Crates.io GitHub issues GitHub

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. 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 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.

Installation

Install the package using cargo

cargo add ainconv

or add the following line to your Cargo.toml file

[dependencies]
ainconv = "0.1.0"

Usage

Word Conversion

use ainconv::{
    convert_kana_to_latn,
    convert_latn_to_kana,
    convert_cyrl_to_latn,
    convert_latn_to_cyrl,
    convert_kana_to_cyrl,
    convert_cyrl_to_kana,
    // ...
}

println!("{}", convert_kana_to_latn("イランカラㇷ゚テ")); // "irankarapte"
println!("{}", convert_latn_to_kana("irankarapte")); // "イランカラㇷ゚テ"
println!("{}", convert_cyrl_to_latn("иранкараптэ")); // "irankarapte"
println!("{}", convert_latn_to_cyrl("irankarapte")); // "иранкараптэ"
println!("{}", convert_cyrl_to_kana("иранкараптэ")); // "イランカラㇷ゚テ"
println!("{}", convert_kana_to_cyrl("イランカラㇷ゚テ")); // "иранкараптэ"

Extra Functionality

Script Detection

Detect the script of a given string.

use ainconv::detect;

println!("{}", detect("aynu")); // "Latn"
println!("{}", detect("アイヌ")); // "Kana"
println!("{}", detect("айну")); // "Cyrl"

Syllable Splitting

use ainconv::separate;

println!("{:?}", separate("eyaykosiramsuypa")); // ["e", "yay", "ko", "si", "ram", "suy", "pa"]

License

MIT License (c) 2024 mkpoli

See also

No runtime deps