Giter Site home page Giter Site logo

khalisfoundation / anvaad-js Goto Github PK

View Code? Open in Web Editor NEW
8.0 10.0 7.0 2.82 MB

Transliteration toolkit for Gurmukhi ASCII to Unicode, romanized and other character sets

Home Page: https://khalisfoundation.github.io/anvaad-js/

License: MIT License

JavaScript 100.00%
transliteration unicode ascii translit gurmukhi english ascii-codes gurmukhi-script letters

anvaad-js's Introduction

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

  • string string The string of letters

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

  • since: 1.0.0

firstLetters

Retrieve the first letter of each word from a string

Parameters

  • words string The string from which to get first letters
  • eng boolean Whether the string is English (optional, default false)
  • simplify boolean Whether to simplify embedded vowels and other characters (eg. E to a, ^ to K)

Examples

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

Returns string Returns a single string of characters

Meta

  • since: 1.0.0

mainLetters

Removes vowel symbols from a Gurmukhi string

Parameters

  • words string The string from which to get main letters
  • simplify boolean Whether to simplify embedded vowels/nasal sounds (eg. E to a, ^ to K)
  • simplifyConsonants boolean Whether to simplify half characters to full characters (eg. R to r)

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

  • since: 1.0.0

translit

Returns a transliteration of Gurmukhi script

Parameters

  • gurmukhi string The string from to generate transliteration

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

  • since: 1.0.0

unicode

Convert Gurmukhi script to Unicode and back again.

Parameters

  • text string Gurbani Akhar or Unicode script to be converted
  • reverse boolean Whether to convert ASCII to unicode (false by default)
  • simplify boolean Whether to simplify extended characters to single code points (eg. sæ to ਸ਼ (u0A36), ਸ਼ (u0A38u0A3C) to S) (false by default)

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

  • since: 1.0.0

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

anvaad-js's People

Contributors

akalustat avatar bogas04 avatar dependabot[bot] avatar gauravjeetsingh avatar gurs1kh avatar gursevaksevadar avatar irvanjitsingh avatar jasneet-singh13 avatar manjots avatar navdeepsinghkhalsa avatar tarunsingh5 avatar tsingh777 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

anvaad-js's Issues

unicode test case causing sihari transposition

something is wrong in the conversion and test for:

ਨੁ ਜੋਗੁ ਕਉਨੁ ਗੵਾਨੁ ਧੵਾਨੁ ਕਵਨ ਬਿਧਿ ਉਸ੍ਤਤਿ ਕਰੀਐ

When copying and pasting to microsoft word, ustat's sihari is after the tatas

screen shot 2018-08-08 at 10 12 30 am

Issues in current devnagri transliteration

I copied japji sahib from sttm.co and transliterated it to hindi using anvaad.translit(..) function.
Then used this and this to compare.

Found eight issues so far. Yellow words are from the above pdf and next to them is our transliterated version.
compare

Will be adding more issues as I find in this ticket.

Potential bug when converting a "ਸ਼" with sihaari

ਵਾਹਿਗੁਰੂਜੀਕਾਖਾਲਸਾਵਾਹਿਗੁਰੂਜੀਕੀਫਤੇ

I noticed a couple of times when I was previewing words like: "ਪੋਸ਼ਿਸ਼" or "ਬਖਸ਼ਿਸ਼" the Gurmukhi script (the English conversion) would be a little off.

Take this example:

anv.unicode('ਸ਼', true); // expects sæ
anv.unicode('ਸ਼ਿ', true); // expects "isæ"
anv.unicode('ਸ਼ਿਸ਼', true); // expects "isæsæ"

But the results are different. Check it out:

Screen Shot 2020-09-20 at 9 58 55 AM

Here is what "ਪੋਸ਼ਿਸ਼" looks like when incorrectly converted using anv.unicide('ਪੋਸ਼ਿਸ਼"', true);. The image below is being displayed with the OpenGurbaniAkhar-Regular.otf font.

Screen Shot 2020-09-20 at 9 59 52 AM

I've only seen this happen with the Sihaari, other vowels are looking good.

Screen Shot 2020-09-20 at 10 21 40 AM

Ik-Oan-Kaar - Style is different now - Unicode Specific Issue

Describe the bug
Unicode Ik-Oan-Kaar symbol is a little distorted now..

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Any Bani with the Ik-Oan-Kaar symbol'
  2. Click on 'Advance'
  3. Change Font selection to Unicode
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
Screenshot 2020-08-19 at 12 12 47 PM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.