Skip to content

mkpoli/ainconv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

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

About

A JavaScript package to convert between Ainu writing systems

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published