-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix issue with suggestions. (#1507)
* fix: Fix issue with suggestions. Case sensitive suggestions were not getting properly processed. * Create issues-lock.yml Note: cspell-trie-lib api changed in this diff. Since it is an internal library, it is not marked as breaking.
- Loading branch information
Showing
15 changed files
with
245 additions
and
51 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,18 @@ | ||
name: "Lock closed issues" | ||
|
||
on: | ||
schedule: | ||
- cron: "30 5 * * *" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
stale: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: dessant/[email protected] | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
issue-lock-comment: "This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs." | ||
issue-lock-inactive-days: 30 | ||
process-only: "issues" | ||
# cspell:ignore dessant |
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
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
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,5 @@ | ||
{ | ||
"import": [ | ||
"@cspell/dict-es-es/cspell-ext.json" | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
@@ -1,17 +1,59 @@ | ||
import { readTrie } from './dictionaries.test.helper'; | ||
import { parseLinesToDictionary } from './SimpleDictionaryParser'; | ||
|
||
function getTrie() { | ||
return readTrie('@cspell/dict-es-es/cspell-ext.json'); | ||
} | ||
|
||
describe('Validate Spanish Suggestions', () => { | ||
test('Tests suggestions', async () => { | ||
// cspell:locale en,es | ||
// cspell:ignore Carmjen | ||
test.each` | ||
word | ignoreCase | expectedWords | ||
${'carmjen'} | ${false} | ${['carmen', 'carmene', 'carmena', 'carmená', 'carmené', 'carmeno', 'carmenó', 'carmenen']} | ||
${'carmjen'} | ${true} | ${['carmen', 'carmene', 'carmena', 'carmená', 'carmené', 'carmeno', 'carmenó', 'carmenen']} | ||
${'carmen'} | ${true} | ${['carmen', 'carmene', 'carmena', 'carmená', 'carmené', 'carmeno', 'carmenó']} | ||
${'carmen'} | ${false} | ${['carmen', 'carmene', 'carmena', 'carmená', 'carmené', 'carmeno', 'carmenó']} | ||
${'cafe'} | ${false} | ${['café', 'cafés', 'cafre', 'cabe', 'cace', 'cale', 'cañe', 'cape', 'case', 'cate', 'cave']} | ||
${'niño'} | ${false} | ${['niño', 'niños', 'niña', 'niñeo']} | ||
${'nino'} | ${false} | ${['niño', 'ninfo', 'niños', 'nido', 'niña', 'nito', 'niñeo']} | ||
${'barcelona'} | ${false} | ${['Barcelona', 'Bárcena', 'parcelan', 'abretona']} | ||
${'Mexico'} | ${false} | ${['México', 'mexica', 'medico', 'medicó', 'médico']} | ||
`('Tests suggestions "$word" ignoreCase: $ignoreCase', async ({ word, ignoreCase, expectedWords }) => { | ||
jest.setTimeout(5000); | ||
const trie = await getTrie(); | ||
// cspell:ignore Carmjen | ||
const results = trie.suggestWithCost('carmjen', 10); | ||
const suggestions = results.map((s) => s.word); | ||
expect(suggestions).toEqual(expect.arrayContaining(['carmen'])); | ||
expect(suggestions[0]).toBe('carmen'); | ||
const suggestions = trie.suggest(word, 4, undefined, undefined, ignoreCase); | ||
expect(suggestions).toEqual(expectedWords); | ||
}); | ||
|
||
test.each` | ||
word | ignoreCase | expectedWords | ||
${'niño'} | ${false} | ${[c('niño', 0), c('niños', 95), c('niña', 96), c('niñeo', 96)]} | ||
${'nino'} | ${false} | ${[c('niño', 1), c('ninfo', 96), c('niños', 96), c('nido', 97), c('niña', 97), c('nito', 97), c('niñeo', 97)]} | ||
`('Tests suggestions "$word" ignoreCase: $ignoreCase', async ({ word, ignoreCase, expectedWords }) => { | ||
jest.setTimeout(5000); | ||
const trie = await getTrie(); | ||
const results = trie.suggestWithCost(word, 4, undefined, undefined, ignoreCase); | ||
expect(results).toEqual(expectedWords); | ||
}); | ||
|
||
test.each` | ||
word | ignoreCase | expectedWords | ||
${'niño'} | ${false} | ${[c('niño', 0), c('niños', 95), c('niña', 96), c('niñeo', 96), c('nido', 97), c('dino', 100)]} | ||
${'nino'} | ${false} | ${[c('niño', 1), c('niños', 96), c('nido', 97), c('niña', 97), c('niñeo', 97), c('dino', 99)]} | ||
`('Tests suggestions "$word" ignoreCase: $ignoreCase', ({ word, ignoreCase, expectedWords }) => { | ||
const trie = trieSimple(); | ||
const results = trie.suggestWithCost(word, 10, undefined, undefined, ignoreCase); | ||
expect(results).toEqual(expectedWords); | ||
}); | ||
}); | ||
|
||
function c(word: string, cost: number) { | ||
return { word, cost }; | ||
} | ||
|
||
const sampleWords = ['niño', 'niños', 'niña', 'niñeo', 'dino', 'nido']; | ||
|
||
function trieSimple() { | ||
return parseLinesToDictionary(sampleWords); | ||
} |
Oops, something went wrong.