Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(toEnglish): properly detect word boundaries #177

Merged
merged 2 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = [
[ /mÚ/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