Skip to content

Commit

Permalink
Fallback when raku-splitting fails (for foreign names)
Browse files Browse the repository at this point in the history
  • Loading branch information
lynn committed Sep 5, 2023
1 parent 505c2cb commit 0e07d46
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/tokenize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,18 @@ export function tone(word: string): Tone {
}

function splitIntoRaku(word: string): string[] {
return [
const raku = [
...word.matchAll(
/(b|c|ch|d|f|g|h|j|k|l|m|n|nh|p|r|s|sh|t|vy?|wy?|ꝡ|y|z|')?[aeiıou]\p{Diacritic}?[aeiıou]*(q|m(?![aeiıou]))?-?/giu,
),
].map(m => {
return m[0];
});
if (raku.reduce((a, b) => a + b.length, 0) === word.length) {
return raku;
} else {
return [word];
}
}

export function splitPrefixes(word: string): {
Expand Down

0 comments on commit 0e07d46

Please sign in to comment.