-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(firstLetters): support hindi, english transliterations and simpl…
- Loading branch information
1 parent
9158e56
commit 11f52c6
Showing
7 changed files
with
64 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,42 @@ | ||
const { expect } = require( 'chai' ) | ||
|
||
const { firstLetters } = require( '../index' ) | ||
const { firstLetters, toHindi, toEnglish } = require( '../index' ) | ||
|
||
|
||
describe( 'firstLetters()', () => { | ||
describe( 'firstLetters(gurmukhi)', () => { | ||
const lines = [ | ||
[ 'hir hir nwmu jphu mn myry muiK gurmuiK pRIiq lgwqI ]', 'hhnjmmmgpl' ], | ||
[ 'iZir&qym sMdUk* drIXw AmIk* ]', 'gsdA' ], | ||
[ 'ijs no ik®pw krih iqin nwmu rqnu pwieAw ]', 'jnkkqnrp' ], | ||
[ 'ਗੁਰਮੁਖਿ ਲਾਧਾ ਮਨਮੁਖਿ ਗਵਾਇਆ ॥', 'ਗਲਮਗ॥' ], | ||
[ 'ਜਿਨਿ ਹਰਿ ਸੇਵਿਆ ਤਿਨਿ ਸੁਖੁ ਪਾਇਆ ॥', 'ਜਹਸਤਸਪ॥' ], | ||
[ 'ਗ਼ੈਰਿ ਹਮਦਿ ਹੱਕ ਨਿਆਇਦ ਬਰ ਜ਼ਬਾਨਮ ਹੀਚ ਗਾਹ', 'ਗ਼ਹਹਨਬਜ਼ਹਗ' ], | ||
[ 'ਸਬਦਿ ਮਰੈ. ਸੋ ਮਰਿ ਰਹੈ; ਫਿਰਿ. ਮਰੈ ਨ, ਦੂਜੀ ਵਾਰ ॥', 'ਸਮ.ਸਮਰ;ਫ.ਮਨ,ਦਵ॥' ], | ||
] | ||
|
||
lines.map( ( [ line, expectedFirstLetters ] ) => it( `should generate first letters for '${line}' as '${expectedFirstLetters}'`, () => { | ||
expect( firstLetters( line ) ).to.equal( expectedFirstLetters ) | ||
} ) ) | ||
} ) | ||
|
||
describe( 'firstLetters() with stripNukta=false', () => { | ||
describe( 'firstLetters(hindi)', () => { | ||
const lines = [ | ||
[ 'iZir&qym sMdUk* drIXw AmIk* ]', 'ZsdA' ], | ||
] | ||
|
||
lines.map( ( [ line, expectedFirstLetters ] ) => it( `should generate first letters for '${line}' as '${expectedFirstLetters}'`, () => { | ||
expect( firstLetters( line, false ) ).to.equal( expectedFirstLetters ) | ||
} ) ) | ||
} ) | ||
|
||
describe( 'firstLetters() with stripNukta=true and withVishraams=true', () => { | ||
const lines = [ | ||
[ 'sbid mrY. so mir rhY; iPir. mrY n, dUjI vwr ]', 'sm.smr;P.mn,dv' ], | ||
] | ||
|
||
lines.map( ( [ line, expectedFirstLetters ] ) => it( `should generate first letters for '${line}' as '${expectedFirstLetters}'`, () => { | ||
expect( firstLetters( line, true, true ) ).to.equal( expectedFirstLetters ) | ||
} ) ) | ||
} ) | ||
|
||
describe( 'firstLetters() with unicode strings', () => { | ||
const lines = [ | ||
[ 'ਗੁਰਮੁਖਿ ਲਾਧਾ ਮਨਮੁਖਿ ਗਵਾਇਆ ॥', 'ਗਲਮਗ' ], | ||
[ 'ਜਿਨਿ ਹਰਿ ਸੇਵਿਆ ਤਿਨਿ ਸੁਖੁ ਪਾਇਆ ॥', 'ਜਹਸਤਸਪ' ], | ||
[ 'ਗ਼ੈਰਿ ਹਮਦਿ ਹੱਕ ਨਿਆਇਦ ਬਰ ਜ਼ਬਾਨਮ ਹੀਚ ਗਾਹ', 'ਗਹਹਨਬਜਹਗ' ], | ||
] | ||
[ 'ਗੁਰਮੁਖਿ ਲਾਧਾ ਮਨਮੁਖਿ ਗਵਾਇਆ ॥', 'गलमग॥' ], | ||
[ 'ਜਿਨਿ ਹਰਿ ਸੇਵਿਆ ਤਿਨਿ ਸੁਖੁ ਪਾਇਆ ॥', 'जहसतसप॥' ], | ||
[ 'ਗ਼ੈਰਿ ਹਮਦਿ ਹੱਕ ਨਿਆਇਦ ਬਰ ਜ਼ਬਾਨਮ ਹੀਚ ਗਾਹ', 'ग़हहनबज़हग' ], | ||
[ 'ਸਬਦਿ ਮਰੈ. ਸੋ ਮਰਿ ਰਹੈ; ਫਿਰਿ. ਮਰੈ ਨ, ਦੂਜੀ ਵਾਰ ॥', 'सम.समर;फ.मन,दव॥' ], | ||
].map( ( [ input, output ] ) => [ toHindi( input ), output ] ) | ||
|
||
lines.map( ( [ line, expectedFirstLetters ] ) => it( `should generate first letters for '${line}' as '${expectedFirstLetters}'`, () => { | ||
expect( firstLetters( line ) ).to.equal( expectedFirstLetters ) | ||
} ) ) | ||
} ) | ||
|
||
describe( 'firstLetters() with unicode strings and stripNukta=false', () => { | ||
const lines = [ | ||
[ 'ਗ਼ੈਰਿ ਹਮਦਿ ਹੱਕ ਨਿਆਇਦ ਬਰ ਜ਼ਬਾਨਮ ਹੀਚ ਗਾਹ,', 'ਗ਼ਹਹਨਬਜ਼ਹਗ' ], | ||
] | ||
|
||
lines.map( ( [ line, expectedFirstLetters ] ) => it( `should generate first letters for '${line}' as '${expectedFirstLetters}'`, () => { | ||
expect( firstLetters( line, false ) ).to.equal( expectedFirstLetters ) | ||
} ) ) | ||
} ) | ||
|
||
describe( 'firstLetters() with unicode strings, stripNukta=true, and withVishraams=true', () => { | ||
describe( 'firstLetters(english)', () => { | ||
const lines = [ | ||
[ 'ਸਬਦਿ ਮਰੈ. ਸੋ ਮਰਿ ਰਹੈ; ਫਿਰਿ. ਮਰੈ ਨ, ਦੂਜੀ ਵਾਰ ॥', 'ਸਮ.ਸਮਰ;ਫ.ਮਨ,ਦਵ' ], | ||
] | ||
[ 'ਗੁਰਮੁਖਿ ਲਾਧਾ ਮਨਮੁਖਿ ਗਵਾਇਆ ॥', 'glmg|' ], | ||
[ 'ਜਿਨਿ ਹਰਿ ਸੇਵਿਆ ਤਿਨਿ ਸੁਖੁ ਪਾਇਆ ॥', 'jhstsp|' ], | ||
[ 'ਗ਼ੈਰਿ ਹਮਦਿ ਹੱਕ ਨਿਆਇਦ ਬਰ ਜ਼ਬਾਨਮ ਹੀਚ ਗਾਹ', 'ghhnbzhg' ], | ||
[ 'ਸਬਦਿ ਮਰੈ. ਸੋ ਮਰਿ ਰਹੈ; ਫਿਰਿ. ਮਰੈ ਨ, ਦੂਜੀ ਵਾਰ ॥', 'sm.smr;f.mn,dv|' ], | ||
].map( ( [ input, output ] ) => [ toEnglish( input ), output ] ) | ||
|
||
lines.map( ( [ line, expectedFirstLetters ] ) => it( `should generate first letters for '${line}' as '${expectedFirstLetters}'`, () => { | ||
expect( firstLetters( line, true, true ) ).to.equal( expectedFirstLetters ) | ||
expect( firstLetters( line ) ).to.equal( expectedFirstLetters ) | ||
} ) ) | ||
} ) |