Skip to content

Anbani/anbani.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

61 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Anbani

tests codecov npm node license

Anbani is a multifunctional toolkit designed for Georgian Alphabet. Main functionalities include text conversion between various Georgian alphabets via anbani.core and random text generation via anbani.lorem.

Installation

To install the package simple grab it from npm

npm install anbani

Initialize package in CommonJS format as follows

const anbani = require('anbani')

Load the module in ESM definition like this

import anbani from "anbani";

You may use it in browser via window global

<script src="https://cdn.jsdelivr.net/npm/anbani@latest/dist/anbani.js"></script>

To try modern module definition in browsers you may include directly from source. (Notice src directory in URL)

<script type="module">
  import anbani from "https://cdn.jsdelivr.net/npm/anbani@latest/src/anbani.mjs";
  ...
</script>

Structure

Here's the structure of the package with four main modules: core for conversion and interpretation of letters, lorem for random text generation, data for accessing the datasets, and toolkit for bonus features.

Minor features from each module are exposed in $, such as anbani.lorem.$.*.

anbani
  โ”œโ”€ core
  โ”‚  โ”œโ”€ convert [Function]
  โ”‚  โ”œโ”€ interpret [Function]
  โ”‚  โ”œโ”€ classify [Function]      // names the source script, or "unknown"
  โ”‚  โ””โ”€ $                        // alias of classify; $.classifyText also works
  โ”œโ”€ lorem
  โ”‚  โ”œโ”€ sentences [Function]
  โ”‚  โ”œโ”€ paragraphs [Function]
  โ”‚  โ”œโ”€ loadWordlist [Function]
  โ”‚  โ”œโ”€ names [Function]
  โ”‚  โ””โ”€ $
  โ”‚     โ”œโ”€ randomFirstName [Function]
  โ”‚     โ”œโ”€ randomLastName [Function]
  โ”‚     โ””โ”€ randomWord [Function]
  โ”œโ”€ toolkit
  โ”‚  โ”œโ”€ friedman [Function]
  โ”‚  โ”œโ”€ frequency [Function]
  โ”‚  โ””โ”€ count [Function]
  โ”œโ”€ nlp
  โ”‚  โ”œโ”€ contractions   { expand, expandText, contract, contractText }
  โ”‚  โ”œโ”€ georgianisation { georgianise, latinise }
  โ”‚  โ””โ”€ preprocessing  { wordTokenize, sentenceTokenize, paragraphTokenize, cleanup }
  โ”œโ”€ ab
  โ”‚  โ”œโ”€ letters { mkhedruli, asomtavruli, nuskhuri, mtavruli } [String]
  โ”‚  โ”œโ”€ keys [Array]
  โ”‚  โ”œโ”€ caps / bicam / bicaps [Function]
  โ””โ”€ data
     โ”œโ”€ alphabets   // per-script letter tables + names + numeric
     โ””โ”€ regex       // per-script detection patterns

Usage

Conversion

anbani.core.convert supports all of the Georgian unicameral and bicameral alphabets for conversion listed bellow and even more. Note that you may use Georgian and Latin letters to pass parameters. It's just a less headache.

// convert(TEXT, FROM, TO)

anbani.core.convert("แƒแƒœแƒ‘แƒแƒœแƒ˜", "แƒ›แƒฎแƒ”แƒ“แƒ แƒฃแƒšแƒ˜", "แƒแƒกแƒแƒ›แƒ—แƒแƒ•แƒ แƒฃแƒšแƒ˜")
// 'แ‚ แ‚ฌแ‚กแ‚ แ‚ฌแ‚จ'

anbani.core.convert("แƒแƒœแƒ‘แƒแƒœแƒ˜", "mkhedruli", "แƒœแƒฃแƒกแƒฎแƒฃแƒ แƒ˜")
// 'โด€โดŒโดโด€โดŒโดˆ'

Georgian also has bicameral styles of the alphabet. If you first hear about that now, check out this article. Generally, automatic capitalization occurs at the beginning of the sentence. However, you can also append the letter with ' symbol in order to capitalize the word during conversion. This trick also works at anbani.ge as well. Here's an example

anbani.core.convert("แƒ'แƒœแƒ‘แƒแƒœแƒ˜", "แƒ›แƒฎแƒ”แƒ“แƒ แƒฃแƒšแƒ˜", "แƒจแƒแƒœแƒ˜แƒซแƒ˜แƒกแƒ”แƒฃแƒšแƒ˜")
// 'แ‚ แƒœแƒ‘แƒแƒœแƒ˜'

anbani.core.convert("แƒ˜'แƒงแƒ แƒ'แƒ แƒแƒ‘แƒ”แƒ—แƒก แƒ 'แƒแƒกแƒขแƒ”แƒ•แƒแƒœ", "mkhedruli", "shanidziseuli")
// 'แ‚จแƒงแƒ แ‚ แƒ แƒแƒ‘แƒ”แƒ—แƒก แ‚ฐแƒแƒกแƒขแƒ”แƒ•แƒแƒœ'

Here are all of the conversions supported. Note that you may convert to any of these types but not all of them are supported to be converted from. In other words, you can only convert from Mkhedruli, Asomtavruli, Nuskhuri, Mtavruli, and Qwerty, since there is no 1-to-1 relation amongst others.

word sentence
names แƒฅแƒแƒœแƒแƒœแƒ แƒแƒ”แƒ—แƒแƒœแƒฃแƒœแƒšแƒแƒกแƒ˜แƒœ แƒ“แƒแƒœแƒแƒœแƒ•แƒ˜แƒœแƒ˜แƒœแƒ—แƒแƒœ แƒแƒœแƒฆแƒแƒœแƒ›แƒแƒœแƒแƒœแƒจแƒ˜แƒœแƒ”แƒœแƒœแƒแƒ แƒ”แƒœแƒ‘แƒแƒœแƒ”แƒœแƒšแƒแƒกแƒ˜แƒœ แƒฅแƒแƒœแƒแƒœแƒ แƒแƒ”แƒ—แƒแƒœแƒ•แƒ˜แƒœแƒ”แƒœแƒšแƒแƒกแƒ—แƒแƒœแƒแƒœ แƒฌแƒ˜แƒšแƒ›แƒแƒœแƒ˜แƒœแƒœแƒแƒ แƒ“แƒแƒœแƒแƒœแƒœแƒแƒ แƒ˜แƒœแƒแƒœ
mkhedruli แƒฅแƒแƒ แƒ—แƒฃแƒšแƒ˜ แƒ“แƒแƒ•แƒ˜แƒ— แƒแƒฆแƒ›แƒแƒจแƒ”แƒœแƒ”แƒ‘แƒ”แƒšแƒ˜ แƒฅแƒแƒ แƒ—แƒ•แƒ”แƒšแƒ—แƒ แƒฌแƒ›แƒ˜แƒœแƒ“แƒแƒœแƒ˜แƒ
mtavruli แฒฅแฒแฒ แฒ—แฒฃแฒšแฒ˜ แฒ“แฒแฒ•แฒ˜แฒ— แฒแฒฆแฒ›แฒแฒจแฒ”แฒœแฒ”แฒ‘แฒ”แฒšแฒ˜ แฒฅแฒแฒ แฒ—แฒ•แฒ”แฒšแฒ—แฒ แฒฌแฒ›แฒ˜แฒœแฒ“แฒแฒœแฒ˜แฒ
asomtavruli แ‚ตแ‚ แ‚ฐแ‚งแ‚ณแ‚ชแ‚จ แ‚ฃแ‚ แ‚ฅแ‚จแ‚ง แ‚ แ‚ถแ‚ซแ‚ แ‚ธแ‚คแ‚ฌแ‚คแ‚กแ‚คแ‚ชแ‚จ แ‚ตแ‚ แ‚ฐแ‚งแ‚ฅแ‚คแ‚ชแ‚งแ‚  แ‚ผแ‚ซแ‚จแ‚ฌแ‚ฃแ‚ แ‚ฌแ‚จแ‚ 
khutsuri แ‚ตโด€โดโด‡โด“โดŠโดˆ แ‚ฃโด€โด…โดˆโด‡ โด€โด–โด‹โด€โด˜โด„โดŒโด„โดโด„โดŠโดˆ โด•โด€โดโด‡โด…โด„โดŠโด‡โด€ โดœโด‹โดˆโดŒโดƒโด€โดŒโดˆโด€
shanidziseuli แ‚ตแƒแƒ แƒ—แƒฃแƒšแƒ˜ แ‚ฃแƒแƒ•แƒ˜แƒ— แƒแƒฆแƒ›แƒแƒจแƒ”แƒœแƒ”แƒ‘แƒ”แƒšแƒ˜ แƒฅแƒแƒ แƒ—แƒ•แƒ”แƒšแƒ—แƒ แƒฌแƒ›แƒ˜แƒœแƒ“แƒแƒœแƒ˜แƒ
tfileliseuli แฒฅแƒแƒ แƒ—แƒฃแƒšแƒ˜ แฒ“แƒแƒ•แƒ˜แƒ— แƒแƒฆแƒ›แƒแƒจแƒ”แƒœแƒ”แƒ‘แƒ”แƒšแƒ˜ แƒฅแƒแƒ แƒ—แƒ•แƒ”แƒšแƒ—แƒ แƒฌแƒ›แƒ˜แƒœแƒ“แƒแƒœแƒ˜แƒ
sasataure แ‚ตแฒแฒ แฒ—แฒฃแฒšแฒ˜ แ‚ฃแฒแฒ•แฒ˜แฒ— แฒแฒฆแฒ›แฒแฒจแฒ”แฒœแฒ”แฒ‘แฒ”แฒšแฒ˜ แฒฅแฒแฒ แฒ—แฒ•แฒ”แฒšแฒ—แฒ แฒฌแฒ›แฒ˜แฒœแฒ“แฒแฒœแฒ˜แฒ
nuskhuri โด•โด€โดโด‡โด“โดŠโดˆ โดƒโด€โด…โดˆโด‡ โด€โด–โด‹โด€โด˜โด„โดŒโด„โดโด„โดŠโดˆ โด•โด€โดโด‡โด…โด„โดŠโด‡โด€ โดœโด‹โดˆโดŒโดƒโด€โดŒโดˆโด€
homoglyph โด•โดขแฆแฆŽแง—โดโ€Žแฆต แ•ฆโดขแง†โ€ŽแฆตแฆŽ โดขโดœโด‹โดข๐‘‡คแ…เฆšแ…ีฑแ…โดโ€Žแฆต โด•โดขแฆแฆŽแง†แ…โดแฆŽโดข แƒฌโด‹โ€Žแฆตเฆšแ•ฆโดขเฆšโ€Žแฆตโดข
phonetic kสฐษ‘rtสฐuli dษ‘vitสฐ ษ‘สmษ‘สƒษ›nษ›bษ›li kสฐษ‘rtสฐvษ›ltสฐษ‘ tอกsสผmindษ‘niษ‘
braille โ ปโ โ —โ ‹โ ฅโ ‡โ Š โ ™โ โ บโ Šโ ‹ โ โ ซโ โ โ ฑโ ‘โ โ ‘โ ƒโ ‘โ ‡โ Š โ ปโ โ —โ ‹โ บโ ‘โ ‡โ ‹โ  โ นโ โ Šโ โ ™โ โ โ Šโ 
common qartuli davit aghmashenebeli qartvelta tsmindania
cyrillic ะบะฐั€ั‚ัƒะปะธ ะดะฐะฒะธั‚ ะฐะณะผะฐัˆะตะฝะตะฑะตะปะธ ะบะฐั€ั‚ะฒะตะปั‚ะฐ ั‚ั†ะผะธะฝะดะฐะฝะธะฐ
greek ฮบฮฑฯฯ„ฮฟฯ…ฮปฮท ฮฝฯ„ฮฑฮฒฮทฯ„ ฮฑฮณฮผฮฑฯƒอฑฮตฮฝฮตฮผฯ€ฮตฮปฮท ฮบฮฑฯฯ„ฮฒฮตฮปฯ„ฮฑ ฯ„ฯƒฮผฮทฮฝฮฝฯ„ฮฑฮฝฮทฮฑ
armenian ึ„ีกีผีฉีธึ‚ีฌีซ ีคีกีพีซีฉ ีกีฒีดีกีทีงีถีงีขีงีฌีซ ึ„ีกีผีฉีพีงีฌีฉีก ีฎีดีซีถีคีกีถีซีก
iso_9984 k'art'uli davit' aแธกmaลกenebeli k'art'velt'a cmindania
national kartuli davit aghmashenebeli kartvelta ts'mindania
bgn k'art'uli davit' aghmashenebeli k'art'velt'a tsmindania
titus kartuli davit aฤกmaลกenebeli kartvelta cฬฃmindania
qwerty qarTuli daviT aRmaSenebeli qarTvelTa wmindania
numeric 600110094003010 416109 17004019005505253010 60011009653091 40004010504150101

If you are wondering what Georgian alphabets look like, or what's the difference between all these latinizations here's the table for that as well. Note: if you are not seeing Mtavruli, that's because it was recently added to Unicode and rollout will probably take a while. You can grab DejaVu fonts that support Mtavruli already.

names แƒแƒœ แƒ‘แƒแƒœ แƒ’แƒแƒœ แƒ“แƒแƒœ แƒ”แƒœ แƒ•แƒ˜แƒœ แƒ–แƒ”แƒœ แƒ—แƒแƒœ แƒ˜แƒœ แƒ™แƒแƒœ แƒšแƒแƒก แƒ›แƒแƒœ แƒœแƒแƒ  แƒแƒœ แƒžแƒแƒ  แƒŸแƒแƒœ แƒ แƒแƒ” แƒกแƒแƒœ แƒขแƒแƒ  แƒฃแƒœ แƒคแƒแƒ  แƒฅแƒแƒœ แƒฆแƒแƒœ แƒงแƒแƒ  แƒจแƒ˜แƒœ แƒฉแƒ˜แƒœ แƒชแƒแƒœ แƒซแƒ˜แƒš แƒฌแƒ˜แƒš แƒญแƒแƒ  แƒฎแƒแƒœ แƒฏแƒแƒœ แƒฐแƒแƒ” แƒ”แƒฒ แƒฒแƒ” แƒณแƒ” แƒดแƒแƒ  แƒฐแƒแƒ” แƒถแƒ˜ แƒทแƒœ แƒธแƒ˜แƒœ แƒ’แƒแƒœ แƒแƒ›แƒแƒขแƒ แƒ˜แƒแƒšแƒ”แƒ‘แƒฃแƒšแƒ˜ แƒแƒ˜แƒœ แƒแƒ›แƒแƒขแƒ แƒ˜แƒแƒšแƒ”แƒ‘แƒฃแƒšแƒ˜ แƒ’แƒแƒ›แƒงแƒแƒคแƒ˜ แƒœแƒแƒ  แƒ›แƒแƒ“แƒ˜แƒคแƒ˜แƒ™แƒแƒขแƒแƒ แƒ˜ แƒแƒ”แƒœ แƒกแƒ˜แƒ›แƒแƒ’แƒ แƒ˜แƒก แƒœแƒ˜แƒจแƒแƒœแƒ˜ แƒšแƒแƒ‘แƒ˜แƒแƒšแƒ˜แƒ–แƒแƒชแƒ˜แƒ˜แƒก แƒœแƒ˜แƒจแƒแƒœแƒ˜ แƒ-แƒฃแƒ›แƒšแƒแƒฃแƒขแƒ˜ แƒ-แƒ›แƒแƒ™แƒ แƒแƒœแƒ˜ แƒ-แƒ›แƒแƒ™แƒ แƒแƒœ-แƒฃแƒ›แƒšแƒแƒฃแƒขแƒ˜ แƒ”-แƒ›แƒแƒ™แƒ แƒแƒœแƒ˜ แƒ˜-แƒ›แƒแƒ™แƒ แƒแƒœแƒ˜ แƒ-แƒฃแƒ›แƒšแƒแƒฃแƒขแƒ˜ แƒ-แƒ›แƒแƒ™แƒ แƒแƒœแƒ˜ แƒ-แƒ›แƒแƒ™แƒ แƒแƒœ-แƒฃแƒ›แƒšแƒแƒฃแƒขแƒ˜ แƒฃ-แƒฃแƒ›แƒšแƒแƒฃแƒขแƒ˜ แƒฃ-แƒ›แƒแƒ™แƒ แƒแƒœแƒ˜ แƒฃ-แƒ›แƒแƒ™แƒ แƒแƒœ-แƒฃแƒ›แƒšแƒแƒฃแƒขแƒ˜ แƒฃ-แƒ‘แƒ แƒฏแƒ’แƒฃ แƒทแƒœ-แƒ›แƒแƒ™แƒ แƒแƒœแƒ˜ แƒฌแƒ”แƒ แƒขแƒ˜แƒšแƒ˜ แƒ›แƒซแƒ˜แƒ›แƒ” แƒ™แƒ˜แƒ—แƒฎแƒ•แƒ˜แƒก แƒœแƒ˜แƒจแƒแƒœแƒ˜ แƒซแƒแƒฎแƒ˜แƒšแƒ˜แƒก แƒœแƒ˜แƒจแƒแƒœแƒ˜ แƒฌแƒ”แƒ แƒขแƒ˜แƒš-แƒ›แƒซแƒ˜แƒ›แƒ” แƒแƒ แƒฌแƒ”แƒ แƒขแƒ˜แƒšแƒ˜
mkhedruli แƒ แƒ‘ แƒ’ แƒ“ แƒ” แƒ• แƒ– แƒ— แƒ˜ แƒ™ แƒš แƒ› แƒœ แƒ แƒž แƒŸ แƒ  แƒก แƒข แƒฃ แƒค แƒฅ แƒฆ แƒง แƒจ แƒฉ แƒช แƒซ แƒฌ แƒญ แƒฎ แƒฏ แƒฐ แƒฑ แƒฒ แƒณ แƒด แƒต แƒถ แƒท แƒธ แƒน แƒบ แƒป แƒผ แƒฝ แƒพ แƒฟ แƒฬˆ แƒฬ„ แƒฬ„ฬˆ แƒ”ฬ„ แƒ˜ฬ„ แƒฬˆ แƒฬ„ แƒฬ„ฬˆ แƒฃฬˆ แƒฃฬ„ แƒฃฬ„ฬˆ แƒฃฬ‚ แƒทฬ„ . , ? ! ; :
mtavruli แฒ แฒ‘ แฒ’ แฒ“ แฒ” แฒ• แฒ– แฒ— แฒ˜ แฒ™ แฒš แฒ› แฒœ แฒ แฒž แฒŸ แฒ  แฒก แฒข แฒฃ แฒค แฒฅ แฒฆ แฒง แฒจ แฒฉ แฒช แฒซ แฒฌ แฒญ แฒฎ แฒฏ แฒฐ แฒฑ แฒฒ แฒณ แฒด แฒต แฒถ แฒท แฒธ แฒน แฒบ แฒฝ แฒพ แฒฟ . , ? ! ; :
asomtavruli แ‚  แ‚ก แ‚ข แ‚ฃ แ‚ค แ‚ฅ แ‚ฆ แ‚ง แ‚จ แ‚ฉ แ‚ช แ‚ซ แ‚ฌ แ‚ญ แ‚ฎ แ‚ฏ แ‚ฐ แ‚ฑ แ‚ฒ แ‚ณ แ‚ด แ‚ต แ‚ถ แ‚ท แ‚ธ แ‚น แ‚บ แ‚ป แ‚ผ แ‚ฝ แ‚พ แ‚ฟ แƒ€ แƒ แƒ‚ แƒƒ แƒ„ แƒ… . , ? ! ; :
nuskhuri โด€ โด โด‚ โดƒ โด„ โด… โด† โด‡ โดˆ โด‰ โดŠ โด‹ โดŒ โด โดŽ โด โด โด‘ โด’ โด“ โด” โด• โด– โด— โด˜ โด™ โดš โด› โดœ โด โดž โดŸ โด  โดก โดข โดฃ โดค โดฅ . , ? ! ; :
homoglyph โดข ีฑ เฌŒ แ•ฆ แ… แง† เญซ แฆŽ โ€Žแฆต เซฉ โด โด‹ เฆš แฆ‚ แฒด เชณ แฆ แ’‘ เฎ•เฏ แง— แฆ€ โด• โดœ แง‡ ๐‘‡ค โดŒ เช‰ แ‘ป แƒฌ แƒญ แ•น โดŸ แฒฑ . , ? ! ; :
phonetic ษ‘ b g d ษ› v z tสฐ i k' l m n ษ” p' ส’ r s t' u pสฐ kสฐ ส q' สƒ tอกสƒ tอกs dอกz tอกsสผ tอกสƒสผ ฯ‡ dอกส’ h eษช j w qสฐ oห f ษ™ ส” ษข ส• โ—Œฬƒ ษ™ . , ? ! ; :
braille โ  โ ƒ โ › โ ™ โ ‘ โ บ โ ต โ ‹ โ Š โ … โ ‡ โ  โ  โ • โ  โ š โ — โ Ž โ ž โ ฅ โ ง โ ป โ ซ โ ฎ โ ฑ โ Ÿ โ ‰ โ ฝ โ น โ ญ โ “ โ ช โ ฏ โ Œ โ ฒ โ ‚ โ ฆ โ – โ † โ ’
common a b g d e v z t i k l m n o p zh r s t u f q gh y sh ch c dz ts tch x j h e i ui x hoi f oa h gh rgh oa . , ? ! ; :
cyrillic ะฐ ะฑ ะณ ะด ะต ะฒ ะท ั‚ ะธ ะบ ะป ะผ ะฝ ะพ ะฟ ะถ ั€ ั ั‚ ัƒ ั„ ะบ ะณ ะบ ัˆ ั‡ ั† ะดะท ั‚ั† ั‚ั‡ ั… ะดะถ ั… ะต ะน ัƒะน ั… ั…ะพ ั„ ะพะฐ ั… ะณ ั€ะณ ะพะฐ . , ? ! ; :
greek ฮฑ ฮผฯ€ ฮณฮณ ฮฝฯ„ ฮต ฮฒ ฮถ ฯ„ ฮท ฮบ ฮป ฮผ ฮฝ ฮฟ ฯ€ ฮถอฑ ฯ ฯƒ ฯ„ ฮฟฯ… ฯˆ ฮบ ฮณ ฮบอฑ ฯƒอฑ ฯ„ฯƒ ฯ„ฯƒ ฮดฮถ ฯ„ฯƒ ฯ„ฯƒอฑ ฮณฯ‡ ฯ„ฮถ อฑ ฮต ฮน ฯ…ฮน ฮบฯ‡ อฑฮฟฮน ฯ† ฮฟฮฑ อฑ ฮณ ฯฮณ ฮฟฮฑ . , ? ! ; :
armenian ีก ีข ีฃ ีค ีง ีพ ีฆ ีฉ ีซ ีฏ ีฌ ีด ีถ ึ… ีบ ีช ีผ ีฝ ีฟ ีธึ‚ ึƒ ึ„ ีฒ ีฏีฐ ีท ีน ึ ีฑ ีฎ ีณ ีญ ีป ีฐ ีง ีซ ีธึ‚ีซ ีญ ีฐึ…ีซ ึ† ีจ ีฐ ีฒ ีผีฒ ีจ . , ? ! ; :
iso_9984 a b g d e v z t' i k l m n o p ลพ r s t u p' k' แธก q ลก ฤ' c' j c ฤ x วฐ h ฤ“ y w แบ–' ล f . , ? ! ; :
national a b g d e v z t i k' l m n o p' zh r s t' u p k gh q' sh ch ts dz ts' ch' kh j h . , ? ! ; :
bgn a b g d e v z t' i k l m n o p zh r s t u p' k' gh q sh ch' ts' dz ts ch kh j h ey j q' . , ? ! ; :
titus a b g d e v z t i แธณ l m n o แน— ลพ r s แนญ u p k ฤก qฬ‡ ลก ฤ c ำก cฬฃ ฤฬฃ x วฏ h ฤ“ y w q ล . , ? ! ; :
qwerty a b g d e v z T i k l m n o p J r s t u f q R y S C c Z w W x j h E I V X H F D Y G L > N < { } . , ? ! ; :
numeric 1 2 3 4 5 6 7 9 10 20 30 40 50 70 80 90 100 200 300 400 500 600 700 800 900 1000 2000 3000 4000 5000 6000 8000 9000 8 60 400 7000 10000 . , ? ! ; :

Interpretation

Apart from straightforward conversion, the package also supports interpretation capabilities via anbani.core.interpret, which automagically detects the language of the text and converts to desired to parameter script.

// function interpret(TEXT, TO)

anbani.core.interpret("iyo arabeTs rostevan mefe RmrTisagan sviani", "mkhedruli")
// 'แƒ˜แƒงแƒ แƒแƒ แƒแƒ‘แƒ”แƒ—แƒก แƒ แƒแƒกแƒขแƒ”แƒ•แƒแƒœ แƒ›แƒ”แƒคแƒ” แƒฆแƒ›แƒ แƒ—แƒ˜แƒกแƒแƒ’แƒแƒœ แƒกแƒ•แƒ˜แƒแƒœแƒ˜'

Random text generation

anbani.lorem supports random text and names generation in Georgian via anbani.lorem.sentences, anbani.lorem.paragraphs, and anbani.lorem.names. Unlike other packages, anbani.lorem utilizes wordlists generated using Neural Networks CHAR-RNN by Andrej Karpathy that represents truly fake Georgian words with all the statistics preserved. The network was trained on Georgian epic "The Knight with the Panther Skin" (แƒ•แƒ”แƒคแƒฎแƒ˜แƒกแƒขแƒงแƒแƒแƒกแƒแƒœแƒ˜) and the names of Georgian poets and writers. Corresponding repo will be forthcoming.

Here's an example for name generation:

anbani.lorem.names(3)
// ['แƒ“แƒแƒ›แƒ”แƒ  แƒ’แƒแƒจแƒ•แƒ˜แƒ—แƒ”แƒšแƒ˜', 'แƒกแƒ˜แƒ‘แƒ แƒงแƒแƒ แƒ—แƒ”แƒšแƒ˜แƒ', 'แƒ’แƒ˜แƒ›แƒแƒš แƒ•แƒแƒฌแƒแƒจแƒ•แƒ˜แƒšแƒ˜']

Here's an example for sentence generation:

// function sentences(WORD_COUNT)

anbani.lorem.sentences(10)
// 'แƒ›แƒแƒ”แƒฎแƒ•แƒ˜แƒ“แƒ”แƒก แƒกแƒ˜แƒขแƒ˜แƒ แƒ”แƒœ แƒ’แƒ˜แƒจแƒ˜แƒฎแƒแƒ แƒœแƒ˜. แƒฌแƒ”แƒ˜แƒ—แƒ แƒ’แƒแƒ›แƒ˜แƒ–แƒ แƒ˜แƒแƒœ, แƒฐแƒฅแƒแƒœแƒ—แƒแƒ•แƒ˜แƒกแƒ—แƒแƒœ แƒ’แƒ”แƒ›แƒ แƒฃแƒคแƒ”แƒœ, แƒฃแƒ™แƒ แƒ—แƒ”แƒ‘แƒแƒ“แƒ”แƒ›แƒœแƒ˜ แƒ›แƒ”แƒกแƒ›แƒแƒœแƒชแƒ แƒ›แƒงแƒ˜แƒ•แƒœแƒ”.'

Here's an example for paragraph generation:

// function paragraphs(
//    WORD_COUNT_PER_PARAGRAPH, 
//    PARAGRAPH_COUNT, 
//    NEWLINE_CHAR="\n\n"
// )

anbani.lorem.paragraphs(20,3)

แƒ’แƒแƒœแƒ“แƒ”แƒ•แƒแƒœแƒ’แƒแƒ แƒ›แƒแƒ”แƒฎแƒ•แƒ˜แƒ“แƒ”แƒก แƒจแƒ”แƒ›แƒแƒ•แƒกแƒญแƒ•แƒ แƒ”แƒขแƒ˜แƒ— แƒฐแƒฅแƒแƒœแƒ—แƒแƒ•แƒ˜แƒกแƒ—แƒแƒœ, แƒ“แƒแƒ•แƒ”แƒฏแƒแƒ แƒ”แƒœแƒ แƒ›แƒ”แƒ’แƒ แƒ”แƒชแƒ. แƒขแƒแƒขแƒ แƒ”แƒกแƒขแƒ˜แƒœแƒ˜. แƒจแƒ”แƒ›แƒแƒ•แƒกแƒญแƒ•แƒ แƒ”แƒขแƒ˜แƒ— แƒ’แƒแƒฃแƒ–แƒแƒ“แƒ แƒแƒšแƒ•แƒ˜แƒ—แƒแƒœแƒ˜ แƒ’แƒแƒ›แƒ˜แƒจแƒ•แƒจแƒ”แƒก แƒ›แƒฃแƒ™แƒแƒ›แƒ“แƒ˜แƒก แƒจแƒ”แƒ›แƒแƒฎแƒแƒœแƒ, แƒ›แƒแƒ•แƒšแƒแƒชแƒ—แƒ แƒ›แƒ”แƒกแƒ›แƒแƒœแƒชแƒ แƒจแƒ”แƒ›แƒแƒฎแƒแƒœแƒ แƒจแƒ”แƒ›แƒฌแƒแƒ•แƒšแƒ˜แƒกแƒ แƒ’แƒแƒกแƒฉแƒ•แƒแƒ“แƒ”แƒ—, แƒ“แƒแƒ‘แƒ˜แƒ—แƒฅแƒ˜แƒก แƒกแƒแƒ—แƒ˜แƒœแƒ”แƒกแƒœแƒ˜.

แƒ›แƒงแƒ˜แƒ•แƒœแƒ”แƒœ, แƒ“แƒแƒ•แƒแƒ—แƒฅแƒ•แƒ”แƒœแƒ แƒ’แƒแƒœแƒแƒ–แƒแƒœแƒ“แƒ แƒ›แƒแƒ แƒ—แƒแƒšแƒ˜แƒžแƒ˜ แƒกแƒ˜แƒžแƒงแƒ แƒ แƒฐแƒฅแƒแƒœแƒ—แƒแƒ•แƒ˜แƒกแƒ—แƒแƒœ. แƒกแƒ˜แƒขแƒ˜แƒ แƒ”แƒœ, แƒฌแƒแƒฎแƒกแƒ˜แƒšแƒ—แƒ, แƒแƒฅแƒแƒ›แƒ“แƒกแƒแƒ’แƒ”แƒ‘แƒ”แƒœ แƒ›แƒแƒแƒ’แƒฎแƒ”แƒ‘แƒ แƒ›แƒ˜แƒ•แƒ˜แƒกแƒชแƒ แƒ’แƒแƒ›แƒ˜แƒจแƒ•แƒจแƒ”แƒก, แƒ›แƒขแƒ”แƒ›แƒฃแƒ แƒกแƒ แƒ›แƒแƒชแƒแƒ“แƒ˜แƒ แƒ›แƒขแƒ”แƒ›แƒฃแƒ แƒกแƒ แƒขแƒแƒขแƒ แƒ”แƒกแƒขแƒ˜แƒœแƒ˜, แƒ’แƒ˜แƒจแƒ•แƒ˜แƒšแƒ. แƒ˜แƒชแƒ˜แƒชแƒแƒ“แƒ แƒฌแƒ”แƒ˜แƒ—แƒ, แƒ›แƒงแƒ˜แƒ•แƒœแƒ”.

แƒกแƒ˜แƒžแƒงแƒ แƒ, แƒ›แƒจแƒ•แƒ”แƒœแƒแƒ“แƒ”แƒœแƒ แƒ›แƒ˜แƒ•แƒ˜แƒกแƒชแƒ แƒฃแƒ™แƒ แƒ—แƒ”แƒ‘แƒแƒ“แƒ”แƒ›แƒœแƒ˜ แƒกแƒแƒ›แƒแƒขแƒ แƒ›แƒแƒแƒกแƒ”แƒฎแƒ”แƒก แƒขแƒ˜แƒ แƒกแƒšแƒ˜แƒ— แƒกแƒ˜แƒžแƒงแƒ แƒ? แƒ’แƒแƒ›แƒ˜แƒจแƒ•แƒจแƒ”แƒก แƒกแƒ”แƒ•แƒœแƒ! แƒ›แƒแƒ แƒ—แƒแƒšแƒ˜แƒžแƒ˜ แƒ•แƒ˜แƒ›แƒชแƒ”. แƒฃแƒ’แƒแƒœแƒ“แƒ”แƒ’แƒ แƒแƒฅแƒแƒ›แƒ“แƒกแƒแƒ’แƒ”แƒ‘แƒ”แƒœ แƒ›แƒ˜แƒฎแƒกแƒ”แƒœแƒ˜แƒ— แƒ›แƒ–แƒšแƒแƒก แƒ›แƒ”แƒ’แƒ แƒ”แƒชแƒ แƒ›แƒขแƒ”แƒ›แƒฃแƒ แƒกแƒ แƒ›แƒ˜แƒ—แƒฎแƒ แƒแƒก แƒ›แƒแƒ›แƒ“แƒ˜แƒฐแƒฎแƒšแƒ”แƒ.'

Note that none of the words generated occur in the training dataset (the poem), but rather are built to mimic underlying constructs of the language. This makes the text feel fully Georgian while actually meaning nothing (which is good, since you don't need to worry about awkward permutation that might ever occur).

Alternatively, you can load up your own wordlist if you want.

anbani.lorem.loadWordlist(["แƒ™แƒแƒžแƒ˜แƒ™แƒ˜", "แƒ’แƒแƒ™แƒแƒžแƒ˜แƒ™แƒ”แƒ‘แƒฃแƒšแƒ", "แƒกแƒแƒ™แƒแƒžแƒ˜แƒ™แƒ”แƒจแƒ˜", "แƒฉแƒแƒ™แƒแƒžแƒ˜แƒ™แƒ”แƒ‘แƒฃแƒšแƒ"])

anbani.lorem.sentences(7)
// 'แƒ’แƒแƒ™แƒแƒžแƒ˜แƒ™แƒ”แƒ‘แƒฃแƒšแƒ แƒ™แƒแƒžแƒ˜แƒ™แƒ˜ แƒฉแƒแƒ™แƒแƒžแƒ˜แƒ™แƒ”แƒ‘แƒฃแƒšแƒ แƒ™แƒแƒžแƒ˜แƒ™แƒ˜! แƒ’แƒแƒ™แƒแƒžแƒ˜แƒ™แƒ”แƒ‘แƒฃแƒšแƒ แƒฉแƒแƒ™แƒแƒžแƒ˜แƒ™แƒ”แƒ‘แƒฃแƒšแƒ แƒกแƒแƒ™แƒแƒžแƒ˜แƒ™แƒ”แƒจแƒ˜.'

Toolkit

As some bonus features, you can calculate letter frequency of the text and Friedman score (coincidence index).

var text = "แƒ˜แƒงแƒ แƒแƒ แƒแƒ‘แƒ”แƒ—แƒก แƒ แƒแƒกแƒขแƒ”แƒ•แƒแƒœ แƒ›แƒ”แƒคแƒ” แƒฆแƒ›แƒ แƒ—แƒ˜แƒกแƒแƒ’แƒแƒœ แƒกแƒ•แƒ˜แƒแƒœแƒ˜"

anbani.toolkit.friedman(text)
// 0.06116642958748222

anbani.toolkit.frequency(text)
/*
{ 
  'แƒ˜': 0.09302325581395349,
  'แƒง': 0.023255813953488372,  
  'แƒ': 0.046511627906976744,  
  'แƒ': 0.13953488372093023,  
  'แƒ ': 0.06976744186046512,  
  'แƒ‘': 0.023255813953488372,  
  'แƒ”': 0.09302325581395349,                                 
  'แƒ—': 0.046511627906976744,  
  'แƒก': 0.09302325581395349,  
  'แƒข': 0.023255813953488372,
  'แƒ•': 0.046511627906976744,  
  'แƒœ': 0.06976744186046512,  
  'แƒ›': 0.046511627906976744,
  'แƒค': 0.023255813953488372,  
  'แƒฆ': 0.023255813953488372,  
  'แƒ’': 0.023255813953488372 
}
*/

RunKit

Here's a RunKit note for the package https://npm.runkit.com/anbani

const anbani = require("anbani")

// Core module
console.log( anbani.core.convert("แƒฅแƒแƒ แƒ—แƒฃแƒšแƒ˜ แƒแƒœแƒ‘แƒแƒœแƒ˜", "แƒ›แƒฎแƒ”แƒ“แƒ แƒฃแƒšแƒ˜", "แƒจแƒแƒœแƒ˜แƒซแƒ˜แƒกแƒ”แƒฃแƒšแƒ˜") )
console.log( anbani.core.interpret("vefxistyaosani", "asomtavruli") )

// Lorem module
console.log( anbani.lorem.sentences(7) ) // param: number of words in total
console.log( anbani.lorem.paragraphs(10, 2) ) // params: number of words per paragraph, number of paragraphs
anbani.lorem.loadWordlist(["แƒแƒœแƒ˜", "แƒ‘แƒแƒœแƒ˜"]) // load custom dataset
console.log( anbani.lorem.sentences(7) )
console.log( anbani.lorem.names(3) ) // param: number of names

// Working with texts
var text = `แƒ แƒแƒ›แƒ”แƒšแƒ›แƒแƒœ แƒจแƒ”แƒฅแƒ›แƒœแƒ แƒกแƒแƒ›แƒงแƒแƒ แƒ แƒซแƒแƒšแƒ˜แƒ—แƒ แƒ›แƒ˜แƒ— แƒซแƒšแƒ˜แƒ”แƒ แƒ˜แƒ—แƒ,
แƒ–แƒ”แƒ’แƒแƒ แƒ“แƒ›แƒ แƒแƒ แƒกแƒœแƒ˜ แƒกแƒฃแƒšแƒ˜แƒ—แƒ แƒงแƒ•แƒœแƒ แƒ–แƒ”แƒชแƒ˜แƒ— แƒ›แƒแƒœแƒแƒ‘แƒ”แƒ แƒ˜แƒ—แƒ,
แƒฉแƒ•แƒ”แƒœ, แƒ™แƒแƒชแƒ—แƒ, แƒ›แƒแƒ’แƒ•แƒชแƒ แƒฅแƒ•แƒ”แƒงแƒแƒœแƒ, แƒ’แƒ•แƒแƒฅแƒ•แƒก แƒฃแƒ—แƒ•แƒแƒšแƒแƒ•แƒ˜ แƒคแƒ”แƒ แƒ˜แƒ—แƒ,
แƒ›แƒ˜แƒกแƒ’แƒแƒœ แƒแƒ แƒก แƒงแƒแƒ•แƒšแƒ˜ แƒฎแƒ”แƒšแƒ›แƒฌแƒ˜แƒคแƒ” แƒกแƒแƒฎแƒ˜แƒ—แƒ แƒ›แƒ˜แƒก แƒ›แƒ˜แƒ”แƒ แƒ˜แƒ—แƒ.`
console.log(`Friedman score: ${anbani.toolkit.friedman(text)}`)

var converted = anbani.core.convert(text, "mkhedruli", "khutsuri")
console.log(`The given text is in '${anbani.core.classify(converted)}' style`)

NLP

Ported from anbani.py: expand/contract Georgian abbreviations, georgianise sloppy qwerty into Georgian, latinise back, and tokenize.

anbani.nlp.contractions.expandText("แƒ•แƒœแƒแƒฎแƒแƒ— แƒ. แƒจ.")
// 'แƒ•แƒœแƒแƒฎแƒแƒ— แƒแƒกแƒ” แƒจแƒ”แƒ›แƒ“แƒ”แƒ’'

anbani.nlp.georgianisation.georgianise("gamarjoba")          // default 'balanced'
// 'แƒ’แƒแƒ›แƒแƒ แƒฏแƒแƒ‘แƒ'
anbani.nlp.georgianisation.georgianise("gamarjoba", "fast")  // no ngram table

anbani.nlp.preprocessing.wordTokenize("แƒ’แƒแƒ›แƒแƒ แƒฏแƒแƒ‘แƒ, แƒ›แƒกแƒแƒคแƒšแƒ˜แƒ!")
// ['แƒ’แƒแƒ›แƒแƒ แƒฏแƒแƒ‘แƒ', 'แƒ›แƒกแƒแƒคแƒšแƒ˜แƒ']

georgianise's balanced mode uses a ~400KB ngram table that ships for Node only; in the browser bundle it throws (use fast). accurate mode is a Python-only extra.

Command line

Installing the package also installs an anbani command:

anbani interpret "gamarjoba"                      # -> แฒ’แฒแฒ›แฒแฒ แฒฏแฒแฒ‘แฒ
anbani convert "แƒแƒœแƒ‘แƒแƒœแƒ˜" mkhedruli asomtavruli
anbani georgianise "gamarjoba"
anbani expand "แƒ•แƒœแƒแƒฎแƒแƒ— แƒ. แƒจ."
anbani lorem 8

Interactive TUI

New in 3.1: a full-screen terminal UI. Launch it with anbani tui, or just run anbani with no arguments inside a terminal (piped/non-TTY use still prints the usage help). Zero extra dependencies โ€” it is hand-rolled ANSI.

anbani tui

anbani tui โ€” loading splash

Five tabs, switch with 1โ€“5 or tab / shift+tab:

Tab What it does
Converter live transliteration; m toggles auto/manual, f/o pick source/target, s swaps
Alphabet letter grid + detail card; hjkl to move, c cycles script, a toggles archaic, enter copies
Lorem fake Georgian text; k kind, +/- amount, g generate
NLP georgianise / latinise / expand / contract; m mode, b georgianise level
Toolkit letter-frequency bars + Friedman index of coincidence

Converter โ€” live transliteration with script auto-detection:

Converter tab

Alphabet โ€” grid + per-letter detail across every Georgian script, IPA, braille, numeral:

Alphabet tab

NLP โ€” georgianise / latinise / expand / contract:

NLP tab

Toolkit โ€” letter-frequency bars and the Friedman index of coincidence:

Toolkit tab

Global keys: ? help overlay ยท i/enter edit ยท y copy (via OSC 52) ยท q or ctrl+c quit. Minimum terminal size is 60ร—16.

Notes:

  • No Georgian keyboard? Pick from: qwerty in the Converter (type Latin, get Georgian), or paste โ€” bracketed paste is supported in edit mode.
  • Copy uses OSC 52; some terminals block it, in which case the copy silently does nothing.

Parity with anbani.py

anbani.js and anbani.py share one behavior contract, proved in CI by the byte-identical spec/golden.json both test suites run. Feature-equivalent as of 3.0; the only intentional gaps are the browser/UMD bundle (js-only) and ebook2text (Python-only).

3.2

  • New core.classify โ€” the blessed name for script classification (matches the core.classify id in the cross-language golden spec).
  • core.$ is now a callable alias of core.classify: core.$(text), core.classify(text) and the older core.$.classifyText(text) all work and return the same thing. Previously core.$ was an object, so core.$(text) threw.
  • core.interpret(null) / interpret(undefined) now throw like other undetectable input (was a silent undefined).
  • Removed the unused utils.isUnsupported.

3.1

  • Interactive terminal UI: anbani tui (or run anbani with no arguments on a TTY).

3.0 โ€” breaking changes

  • Package is now GPL-3.0 (was MIT); ESM by default ("type":"module" + exports map) โ€” deep imports of src/lib/* are no longer allowed, use the public API.
  • core.convert / core.interpret throw an Error on an unsupported source or target (was a silent passthrough).
  • core.interpret throws when the source script can't be detected (mixed / undetectable input); utils.classifyText returns "unknown" there and reports the four bicameral scripts.

What else

The code is under the GPL-3.0 license, freely distributed for anyone who wants to use it (just don't forget to mention the source).

Pull requests and collabs are most welcome!

Cheers,
George แƒป anbani.ge


Packages

 
 
 

Contributors

Languages