Skip to content

Latest commit

 

History

History
94 lines (65 loc) · 3.36 KB

README.md

File metadata and controls

94 lines (65 loc) · 3.36 KB

ainconv - Ainu language script converter

npm GitHub issues npm GitHub

Overview

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

Currently, Latin (Romanization), Katakana, Cyrillic and Hangul 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. The converted string are always in lower case.

Important Note

Conversion between Latin, Cyrillic and Hangul 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 npm (or bun, yarn, pnpm, etc.)

npm install ainconv

Usage

Word Conversion

import { convert } from 'ainconv';

console.log(convert('イランカラㇷ゚テ', 'Kana', 'Latn')); // 'irankarapte'
console.log(convert('irankarapte', 'Latn', 'Kana')); // 'イランカラㇷ゚テ'
console.log(convert('иранкараптэ', 'Cyrl', 'Latn')); // 'irankarapte'
console.log(convert('irankarapte', 'Latn', 'Cyrl')); // 'иранкараптэ'
console.log(convert('이란가랍더', 'Hang', 'Latn')); // 'irankarapte'
console.log(convert('irankarapte', 'Latn', 'Hang')); // '이란가랍더'

// or use the alternative api

import {
    convertLatnToKana,
    convertKanaToCyrl,
    // ...
} from 'ainconv';
convertLatnToKana('aynukotan'); // 'アイヌコタン'
convertKanaToCyrl('アイヌコタン'); // аинукотан

Extra Functionality

Script Detection

Detect the script of a given string.

import { detect } from 'ainconv';

console.log(detect('aynu')); // 'Latn'
console.log(detect('アイヌ')); // 'Kana'
console.log(detect('айну')); // 'Cyrl'
console.log(detect('애누')); // 'Hang'

Syllable Splitting

import { separate } from 'ainconv';

console.log(separate('eyaykosiramsuypa')); // [ 'e', 'yay', 'ko', 'si', 'ram', 'suy', 'pa' ]

Development

We use bun as the build tool.

Build

bun run build

Test

bun test

License

MIT License (c) 2023 mkpoli

See also