Crates.io | ainconv |
lib.rs | ainconv |
version | 0.2.0 |
source | src |
created_at | 2024-02-28 10:05:47.039486 |
updated_at | 2024-11-05 08:46:51.063442 |
description | Converts Ainu words between different scripts (Katakana, Latin, Cyrillic) |
homepage | |
repository | https://github.com/mkpoli/ainconv-rs |
max_upload_size | |
id | 1156284 |
size | 46,246 |
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.
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.
Install the package using cargo
cargo add ainconv
or add the following line to your Cargo.toml
file
[dependencies]
ainconv = "0.1.0"
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("イランカラㇷ゚テ")); // "иранкараптэ"
Detect the script of a given string.
use ainconv::detect;
println!("{}", detect("aynu")); // "Latn"
println!("{}", detect("アイヌ")); // "Kana"
println!("{}", detect("айну")); // "Cyrl"
use ainconv::separate;
println!("{:?}", separate("eyaykosiramsuypa")); // ["e", "yay", "ko", "si", "ram", "suy", "pa"]
MIT License (c) 2024 mkpoli