-
-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lyra): removes diacritics to keep index smaller
implements #75
- Loading branch information
1 parent
929a6cd
commit e8396c3
Showing
3 changed files
with
35 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const diacritics = [ | ||
{ char: "A", base: /[\300-\306]/g }, | ||
{ char: "a", base: /[\340-\346]/g }, | ||
{ char: "E", base: /[\310-\313]/g }, | ||
{ char: "e", base: /[\350-\353]/g }, | ||
{ char: "I", base: /[\314-\317]/g }, | ||
{ char: "i", base: /[\354-\357]/g }, | ||
{ char: "O", base: /[\322-\330]/g }, | ||
{ char: "o", base: /[\362-\370]/g }, | ||
{ char: "U", base: /[\331-\334]/g }, | ||
{ char: "u", base: /[\371-\374]/g }, | ||
{ char: "N", base: /[\321]/g }, | ||
{ char: "n", base: /[\361]/g }, | ||
{ char: "C", base: /[\307]/g }, | ||
{ char: "c", base: /[\347]/g }, | ||
]; | ||
|
||
export function replaceDiacritics(str: string): string { | ||
for (const { char, base } of diacritics) { | ||
str = str.replace(base, char); | ||
} | ||
return str; | ||
} |
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