-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,794 additions
and
59 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 |
---|---|---|
@@ -1 +1 @@ | ||
lts/fermium | ||
lts/hydrogen |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env node | ||
|
||
import fs from 'node:fs'; | ||
import utils from '../dist/index.js'; | ||
|
||
function* extractWords(str) { | ||
// include letters and combining marks | ||
const regex = /([\p{L}\p{M}]+)/gu; | ||
let match; | ||
|
||
while ((match = regex.exec(str)) !== null) { | ||
yield match[1]; | ||
} | ||
} | ||
|
||
function* extractWordsFromFile(filePath) { | ||
const raw = fs.readFileSync(filePath, 'utf8'); | ||
yield* extractWords(raw); | ||
} | ||
|
||
function* allWords() { | ||
yield* extractWordsFromFile('src/adjective/testCases.json'); | ||
yield* extractWordsFromFile('src/noun/__snapshots__/declensionNoun.test.ts.snap'); | ||
yield* extractWordsFromFile('src/numeral/testCases.json'); | ||
yield* extractWordsFromFile('src/pronoun/testCases.json'); | ||
yield* extractWordsFromFile('src/verb/testCases.json'); | ||
} | ||
|
||
function endsWithNj(word) { | ||
return word.endsWith('nja') | ||
|| word.endsWith('njah') | ||
|| word.endsWith('njam') | ||
|| word.endsWith('njami') | ||
|| word.endsWith('nje') | ||
|| word.endsWith('njem') | ||
|| word.endsWith('nju'); | ||
} | ||
|
||
function buildExceptionList() { | ||
const set = new Set(); | ||
for (const word of allWords()) { | ||
if (endsWithNj(word)) { | ||
set.add(utils.transliterate(word.toLowerCase(), 'art-Latn-x-interslv')); | ||
} | ||
} | ||
return [...set].sort(); | ||
} | ||
|
||
function toTrieToken(word) { | ||
return '%' + word.split('').reverse().join('') + '%'; | ||
} | ||
|
||
console.log(buildExceptionList().map(toTrieToken).join(' ')); | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface Dict { | ||
[key: string]: Dict | number; | ||
} |
Oops, something went wrong.