KhalisFoundation / anvaad-js

Transliteration toolkit for Gurmukhi ASCII to Unicode, romanized and other character sets
https://khalisfoundation.github.io/anvaad-js/
MIT License
7 stars 8 forks source link
ascii ascii-codes english gurmukhi gurmukhi-script letters translit transliteration unicode

anvaad-js :: ਅਨੁਵਾਦ-ਜੇਅੈਸ

Build Status Coverage Status

Playground

Visit playground website to try the API methods.

Installation

# npm
npm install anvaad-js
# yarn
yarn add anvaad-js

Usage

import * as anvaad from 'anvaad-js' // ES2015 module syntax
// import { unicode } from 'anvaad-js' // ES2015 module destructuring syntax
// const anvaad = require('anvaad-js') // common-js require syntax

anvaad.unicode('myry');

Testing

We use jest for our tests. Run them using npm/yarn

# npm
npm run test
# yarn
yarn test

API Documentation

Table of Contents

ascii

Returns a comma-separated string of ascii codes for a string of Gurmukhi characters

Parameters

Examples

ascii('AmgAmqmgkp');
// => ',065,109,103,065,109,113,109,103,107,112,'

Returns string Returns a single string of comma-separated ascii codes

Meta

firstLetters

Retrieve the first letter of each word from a string

Parameters

Examples

firstLetters('Awie imlu gurisK Awie imlu qU myry gurU ky ipAwry ]');
// => 'AmgAmqmgkp'

Returns string Returns a single string of characters

Meta

mainLetters

Removes vowel symbols from a Gurmukhi string

Parameters

Examples

mainLetters('Awie imlu gurisK Awie imlu qU myry gurU ky ipAwry ]');
// => 'Ae ml grsK Ae ml q mr gr k pAr'

Returns string Returns a single string of characters

Meta

pauses

Returns a list of all pauses for a string of Gurmukhi words

Parameters

Examples

pauses('ieknw. hukmI bKsIs; ieik, hukmI sdw BvweIAih ]');
// => '[{"p": 0, "t": "t"}, {"p": 2, "t": "v"}, {"p": 3, "t": "j"}]'

Returns JSON Returns a JSON string containing position ('p') and the type of pause ('v' = 'vishraam', 'j' = 'jamki', 't' = 'thamki')

Meta

translit

Returns a transliteration of Gurmukhi script

Parameters

Examples

translit('Awie imlu gurisK Awie imlu qU myry gurU ky ipAwry ]');
// => 'aai mil gurasikh aai mil too mayray guroo kay piaaaray ||'

Returns string Returns a string of text

Meta

unicode

Convert Gurmukhi script to Unicode and back again.

Parameters

Examples

unicode('Awie imlu gurisK Awie imlu qU myry gurU ky ipAwry ]');
// => 'ਆਇ ਮਿਲੁ ਗੁਰਸਿਖ ਆਇ ਮਿਲੁ ਤੂ ਮੇਰੇ ਗੁਰੂ ਕੇ ਪਿਆਰੇ ॥'

Returns string Returns unicode text

 * unicode('ਆਇ ਮਿਲੁ ਗੁਰਸਿਖ ਆਇ ਮਿਲੁ ਤੂ ਮੇਰੇ ਗੁਰੂ ਕੇ ਪਿਆਰੇ ॥', true);
 * // => 'Awie imlu gurisK Awie imlu qU myry gurU ky ipAwry ]'

Returns string Returns gurbani akhar ascii text

Meta

Notes

All letter conversions at a minimum must address the following letters that are utilized within gurbani ascii fonts:

´
`
^
¨
~
<
>
|
µ
[
]
®
@
¤
\
&
˜
†
æ
¡
Å
0
1
2
3
4
5
6
7
8
9
a
A
b
B
c
C
ç
d
D
e
E
f
F
g
G
h
H
i
I
Í
î
Î
Ï
j
J
k
K
l
L
m
M
n
N
o
O
Ø
œ
p
P
q
Q
r
R
s
S
t
T
ŧ
u
U
Ú
ü
v
V
w
W
x
X
y
Y
z
Z