Skip to content

Commit

Permalink
fix(toEnglish): properly detect word boundaries (#177)
Browse files Browse the repository at this point in the history
#Patch release

Co-authored-by: Harjot Singh <harjot@harkul.com>
  • Loading branch information
bhajneet and Harjot1Singh committed Nov 3, 2020
1 parent 4adbf3f commit 76925a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/toEnglish.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const replacements = [
[ //g, 'mhlw' ], // Mehla replcement
[ /i(.)/g, '$1i' ], // Place sihari in correct position
[ /(.)[i]([R®H§´ÍÏ眘†])/ug, '$1$2i' ], // Move sihari in front of pairin akhars
[ new RegExp( `(\\S[^ha])([iu])([\\s$${vishraams.join( '' )}])`, 'ug' ), '$1$3' ], // Remove trailing Aunkar (u) and Sihari (i) except when on Haha (h), Ooraa (a), or on a standalone akhar
[ new RegExp( `(\\S[^ha])[iu]([${vishraams.join( '' )}]|\\b)`, 'ug' ), '$1$2' ], // Remove trailing Aunkar (u) and Sihari (i) except when on Haha (h), Ooraa (a), or on a standalone akhar
[ new RegExp( `(\\b\\S)h([^iIuUyYwWoONM§¨®´µÍÏçüœˆ˜†]\\b|[${vishraams.join( '' )}])`, 'ug' ), '$1yh$2' ], // Add y to three consonant letter words with haha in middle per issue #123
]

Expand Down
6 changes: 6 additions & 0 deletions test/toEnglish.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ const transliterations = [
[ 'ਸਹਜ; ਸਸਹਜ ਅਨਹਦ ਰਹਤ ਕਹਤ ਪਹਰ, ਸਹਸ ਮਹਲ ਟਹਲ ਕਹਨਨ ਕਹਨ', 'sehaj; sasahaj anahad rehat kehat pehar, sehas mehal ttehal kahanan kehan' ],
[ 'ਸਭ ਭਇਓ ਪਰਾਇਓ', 'sabh bheo paraaeo' ],
[ 'ਆਸਾ ਮਹਲਾ ੫ ਪੰਚਪਦੇ₃ ॥', 'aasaa mahalaa 5 panchapade₃ |' ],
[ 'ਹਰਿ', 'har' ],
[ 'ਸਚੁ', 'sach' ],
[ 'ਰਾਹੁ', 'raahu' ],
[ 'ਭਾਉ', 'bhaau' ],
[ 'ਸਤਿਗੁਰੁ ਸਤਿਗੁਰੁ ਸਚੁ; ਸਚੁ ਹਰਿ ਹਰਿ ਹਿੰਙੁ', 'satigur satigur sach; sach har har hing' ],
[ 'ਸੁ ਉ ਜੁ', 'su u ju' ],
]

describe( 'toEnglish()', () => {
Expand Down

0 comments on commit 76925a6

Please sign in to comment.