cspell-dictionary 6.27.0 → 6.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/CachingDictionary.d.ts +3 -3
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/CachingDictionary.js +9 -9
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/FlagWordsDictionary.d.ts +1 -1
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/FlagWordsDictionary.js +11 -11
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/IgnoreWordsDictionary.d.ts +1 -1
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/IgnoreWordsDictionary.js +5 -5
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionary.d.ts +7 -0
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionaryCollection.d.ts +1 -1
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionaryCollection.js +12 -12
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionaryFromTrie.d.ts +3 -2
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionaryFromTrie.js +18 -17
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionaryMethods.d.ts +1 -1
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionaryMethods.js +5 -5
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SuggestDictionary.d.ts +2 -2
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SuggestDictionary.js +9 -9
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Terms/index.d.ts +1 -1
- package/dist/cjs/SpellingDictionary/Typos/index.d.ts +4 -0
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Typos/index.js +7 -7
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Typos/typos.d.ts +1 -1
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Typos/typosParser.d.ts +1 -1
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Typos/typosParser.js +6 -6
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Typos/util.d.ts +1 -1
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/TyposDictionary.d.ts +2 -2
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/TyposDictionary.js +10 -10
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/createInlineSpellingDictionary.d.ts +1 -1
- package/dist/cjs/SpellingDictionary/createInlineSpellingDictionary.js +25 -0
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/createSpellingDictionary.d.ts +2 -2
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/createSpellingDictionary.js +9 -9
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/index.d.ts +10 -10
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/index.js +20 -20
- package/dist/{index.d.ts → cjs/index.d.ts} +2 -2
- package/dist/{index.js → cjs/index.js} +11 -11
- package/dist/{util → cjs/util}/clean.d.ts +1 -1
- package/dist/cjs/util/repMap.d.ts +27 -0
- package/dist/cjs/util/repMap.js +158 -0
- package/dist/{util → cjs/util}/textMappers.js +2 -2
- package/dist/esm/SpellingDictionary/CachingDictionary.d.mts +30 -0
- package/dist/esm/SpellingDictionary/CachingDictionary.mjs +45 -0
- package/dist/esm/SpellingDictionary/FlagWordsDictionary.d.mts +11 -0
- package/dist/esm/SpellingDictionary/FlagWordsDictionary.mjs +134 -0
- package/dist/esm/SpellingDictionary/IgnoreWordsDictionary.d.mts +11 -0
- package/dist/esm/SpellingDictionary/IgnoreWordsDictionary.mjs +96 -0
- package/dist/esm/SpellingDictionary/SpellingDictionary.d.mts +150 -0
- package/dist/esm/SpellingDictionary/SpellingDictionary.mjs +4 -0
- package/dist/esm/SpellingDictionary/SpellingDictionaryCollection.d.mts +16 -0
- package/dist/esm/SpellingDictionary/SpellingDictionaryCollection.mjs +111 -0
- package/dist/esm/SpellingDictionary/SpellingDictionaryFromTrie.d.mts +50 -0
- package/dist/esm/SpellingDictionary/SpellingDictionaryFromTrie.mjs +172 -0
- package/dist/esm/SpellingDictionary/SpellingDictionaryMethods.d.mts +26 -0
- package/dist/esm/SpellingDictionary/SpellingDictionaryMethods.mjs +96 -0
- package/dist/esm/SpellingDictionary/SuggestDictionary.d.mts +20 -0
- package/dist/esm/SpellingDictionary/SuggestDictionary.mjs +97 -0
- package/dist/esm/SpellingDictionary/Terms/index.d.mts +2 -0
- package/dist/esm/SpellingDictionary/Terms/index.mjs +1 -0
- package/dist/esm/SpellingDictionary/Terms/terms.d.mts +12 -0
- package/dist/esm/SpellingDictionary/Terms/terms.mjs +1 -0
- package/dist/esm/SpellingDictionary/Typos/index.d.mts +4 -0
- package/dist/esm/SpellingDictionary/Typos/index.mjs +2 -0
- package/dist/esm/SpellingDictionary/Typos/typos.d.mts +18 -0
- package/dist/esm/SpellingDictionary/Typos/typos.mjs +1 -0
- package/dist/esm/SpellingDictionary/Typos/typosParser.d.mts +34 -0
- package/dist/esm/SpellingDictionary/Typos/typosParser.mjs +131 -0
- package/dist/esm/SpellingDictionary/Typos/util.d.mts +31 -0
- package/dist/esm/SpellingDictionary/Typos/util.mjs +105 -0
- package/dist/esm/SpellingDictionary/TyposDictionary.d.mts +21 -0
- package/dist/esm/SpellingDictionary/TyposDictionary.mjs +129 -0
- package/dist/esm/SpellingDictionary/createInlineSpellingDictionary.d.mts +3 -0
- package/dist/esm/SpellingDictionary/createInlineSpellingDictionary.mjs +20 -0
- package/dist/esm/SpellingDictionary/createSpellingDictionary.d.mts +23 -0
- package/dist/esm/SpellingDictionary/createSpellingDictionary.mjs +68 -0
- package/dist/esm/SpellingDictionary/defaults.d.mts +3 -0
- package/dist/esm/SpellingDictionary/defaults.mjs +2 -0
- package/dist/esm/SpellingDictionary/index.d.mts +11 -0
- package/dist/esm/SpellingDictionary/index.mjs +9 -0
- package/dist/esm/index.d.mts +3 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/util/AutoCache.d.mts +25 -0
- package/dist/esm/util/AutoCache.mjs +67 -0
- package/dist/esm/util/AutoResolve.d.mts +21 -0
- package/dist/esm/util/AutoResolve.mjs +52 -0
- package/dist/esm/util/IterableLike.d.mts +4 -0
- package/dist/esm/util/IterableLike.mjs +1 -0
- package/dist/esm/util/clean.d.mts +7 -0
- package/dist/esm/util/clean.mjs +13 -0
- package/dist/esm/util/regexHelper.d.mts +7 -0
- package/dist/esm/util/regexHelper.mjs +8 -0
- package/dist/esm/util/repMap.d.mts +27 -0
- package/dist/esm/util/repMap.mjs +152 -0
- package/dist/esm/util/simpleCache.d.mts +46 -0
- package/dist/esm/util/simpleCache.mjs +135 -0
- package/dist/esm/util/text.d.mts +10 -0
- package/dist/esm/util/text.mjs +46 -0
- package/dist/esm/util/textMappers.d.mts +3 -0
- package/dist/esm/util/textMappers.mjs +15 -0
- package/dist/esm/util/types.d.mts +7 -0
- package/dist/esm/util/types.mjs +1 -0
- package/dist/esm/util/util.d.mts +2 -0
- package/dist/esm/util/util.mjs +3 -0
- package/package.json +29 -20
- package/dist/SpellingDictionary/Typos/index.d.ts +0 -4
- package/dist/SpellingDictionary/createInlineSpellingDictionary.js +0 -25
- package/dist/util/repMap.d.ts +0 -11
- package/dist/util/repMap.js +0 -65
- /package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionary.js +0 -0
- /package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Terms/index.js +0 -0
- /package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Terms/terms.d.ts +0 -0
- /package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Terms/terms.js +0 -0
- /package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Typos/typos.js +0 -0
- /package/dist/{SpellingDictionary → cjs/SpellingDictionary}/Typos/util.js +0 -0
- /package/dist/{SpellingDictionary → cjs/SpellingDictionary}/defaults.d.ts +0 -0
- /package/dist/{SpellingDictionary → cjs/SpellingDictionary}/defaults.js +0 -0
- /package/dist/{util → cjs/util}/AutoCache.d.ts +0 -0
- /package/dist/{util → cjs/util}/AutoCache.js +0 -0
- /package/dist/{util → cjs/util}/AutoResolve.d.ts +0 -0
- /package/dist/{util → cjs/util}/AutoResolve.js +0 -0
- /package/dist/{util → cjs/util}/IterableLike.d.ts +0 -0
- /package/dist/{util → cjs/util}/IterableLike.js +0 -0
- /package/dist/{util → cjs/util}/clean.js +0 -0
- /package/dist/{util → cjs/util}/regexHelper.d.ts +0 -0
- /package/dist/{util → cjs/util}/regexHelper.js +0 -0
- /package/dist/{util → cjs/util}/simpleCache.d.ts +0 -0
- /package/dist/{util → cjs/util}/simpleCache.js +0 -0
- /package/dist/{util → cjs/util}/text.d.ts +0 -0
- /package/dist/{util → cjs/util}/text.js +0 -0
- /package/dist/{util → cjs/util}/textMappers.d.ts +0 -0
- /package/dist/{util → cjs/util}/types.d.ts +0 -0
- /package/dist/{util → cjs/util}/types.js +0 -0
- /package/dist/{util → cjs/util}/util.d.ts +0 -0
- /package/dist/{util → cjs/util}/util.js +0 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { opConcatMap, pipe } from '@cspell/cspell-pipe/sync';
|
|
2
|
+
import { CompoundWordsMethod, importTrie, suggestionCollector, Trie } from 'cspell-trie-lib';
|
|
3
|
+
import { autoCache, createCache01 } from '../util/AutoCache.mjs';
|
|
4
|
+
import { clean } from '../util/clean.mjs';
|
|
5
|
+
import { createMapper, createRepMapper } from '../util/repMap.mjs';
|
|
6
|
+
import * as Defaults from './defaults.mjs';
|
|
7
|
+
import { createWeightMapFromDictionaryInformation, defaultNumSuggestions, hasOptionToSearchOption, impersonateCollector, suggestArgsToSuggestOptions, wordSearchForms, wordSuggestFormsArray, } from './SpellingDictionaryMethods.mjs';
|
|
8
|
+
const findWordOptionsCaseSensitive = Object.freeze({ caseSensitive: true });
|
|
9
|
+
const findWordOptionsNotCaseSensitive = Object.freeze({ caseSensitive: false });
|
|
10
|
+
export class SpellingDictionaryFromTrie {
|
|
11
|
+
constructor(trie, name, options, source = 'from trie', size) {
|
|
12
|
+
this.trie = trie;
|
|
13
|
+
this.name = name;
|
|
14
|
+
this.options = options;
|
|
15
|
+
this.source = source;
|
|
16
|
+
this._size = 0;
|
|
17
|
+
this.knownWords = new Set();
|
|
18
|
+
this.unknownWords = new Set();
|
|
19
|
+
this.type = 'SpellingDictionaryFromTrie';
|
|
20
|
+
this._find = findCache((word, useCompounds, ignoreCase) => this.findAnyForm(word, useCompounds, ignoreCase));
|
|
21
|
+
this._isForbidden = autoCache((word) => {
|
|
22
|
+
return this.trie.isForbiddenWord(word);
|
|
23
|
+
});
|
|
24
|
+
this.mapWord = createMapper(options.repMap, options.dictionaryInformation?.ignore);
|
|
25
|
+
this.remapWord = createRepMapper(options.repMap, options.dictionaryInformation?.ignore);
|
|
26
|
+
this.isDictionaryCaseSensitive = options.caseSensitive ?? !trie.isLegacy;
|
|
27
|
+
this.containsNoSuggestWords = options.noSuggest || false;
|
|
28
|
+
this._size = size || 0;
|
|
29
|
+
this.weightMap = options.weightMap || createWeightMapFromDictionaryInformation(options.dictionaryInformation);
|
|
30
|
+
}
|
|
31
|
+
get size() {
|
|
32
|
+
if (!this._size) {
|
|
33
|
+
// walk the trie and get the approximate size.
|
|
34
|
+
const i = this.trie.iterate();
|
|
35
|
+
let deeper = true;
|
|
36
|
+
let size = 0;
|
|
37
|
+
for (let r = i.next(); !r.done; r = i.next(deeper)) {
|
|
38
|
+
// count all nodes even though they are not words.
|
|
39
|
+
// because we are not going to all the leaves, this should give a good enough approximation.
|
|
40
|
+
size += 1;
|
|
41
|
+
deeper = r.value.text.length < 5;
|
|
42
|
+
}
|
|
43
|
+
this._size = size;
|
|
44
|
+
}
|
|
45
|
+
return this._size;
|
|
46
|
+
}
|
|
47
|
+
has(word, hasOptions) {
|
|
48
|
+
const { useCompounds, ignoreCase } = this.resolveOptions(hasOptions);
|
|
49
|
+
const r = this._find(word, useCompounds, ignoreCase);
|
|
50
|
+
return !!r && !r.forbidden && !!r.found;
|
|
51
|
+
}
|
|
52
|
+
find(word, hasOptions) {
|
|
53
|
+
const { useCompounds, ignoreCase } = this.resolveOptions(hasOptions);
|
|
54
|
+
const r = this._find(word, useCompounds, ignoreCase);
|
|
55
|
+
const { forbidden = this.isForbidden(word) } = r || {};
|
|
56
|
+
if (!r && !forbidden)
|
|
57
|
+
return undefined;
|
|
58
|
+
const { found = forbidden ? word : false } = r || {};
|
|
59
|
+
const noSuggest = found !== false && this.containsNoSuggestWords;
|
|
60
|
+
return { found, forbidden, noSuggest };
|
|
61
|
+
}
|
|
62
|
+
resolveOptions(hasOptions) {
|
|
63
|
+
const { useCompounds = this.options.useCompounds, ignoreCase = Defaults.ignoreCase } = hasOptionToSearchOption(hasOptions);
|
|
64
|
+
return { useCompounds, ignoreCase };
|
|
65
|
+
}
|
|
66
|
+
findAnyForm(word, useCompounds, ignoreCase) {
|
|
67
|
+
const outerForms = outerWordForms(word, this.remapWord ? this.remapWord : (word) => [this.mapWord(word)]);
|
|
68
|
+
for (const form of outerForms) {
|
|
69
|
+
const r = this._findAnyForm(form, useCompounds, ignoreCase);
|
|
70
|
+
if (r)
|
|
71
|
+
return r;
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
_findAnyForm(mWord, useCompounds, ignoreCase) {
|
|
76
|
+
const opts = ignoreCase ? findWordOptionsNotCaseSensitive : findWordOptionsCaseSensitive;
|
|
77
|
+
const findResult = this.trie.findWord(mWord, opts);
|
|
78
|
+
if (findResult.found !== false) {
|
|
79
|
+
return findResult;
|
|
80
|
+
}
|
|
81
|
+
const forms = wordSearchForms(mWord, this.isDictionaryCaseSensitive, ignoreCase);
|
|
82
|
+
for (const w of forms) {
|
|
83
|
+
const findResult = this.trie.findWord(w, opts);
|
|
84
|
+
if (findResult.found !== false) {
|
|
85
|
+
return findResult;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (useCompounds) {
|
|
89
|
+
const optsUseCompounds = { ...opts, useLegacyWordCompounds: useCompounds };
|
|
90
|
+
for (const w of forms) {
|
|
91
|
+
const findResult = this.trie.findWord(w, optsUseCompounds);
|
|
92
|
+
if (findResult.found !== false) {
|
|
93
|
+
return findResult;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
isNoSuggestWord(word, options) {
|
|
100
|
+
return this.containsNoSuggestWords ? this.has(word, options) : false;
|
|
101
|
+
}
|
|
102
|
+
isForbidden(word, _ignoreCaseAndAccents) {
|
|
103
|
+
return this._isForbidden(word);
|
|
104
|
+
}
|
|
105
|
+
suggest(...args) {
|
|
106
|
+
const [word] = args;
|
|
107
|
+
const suggestOptions = suggestArgsToSuggestOptions(args);
|
|
108
|
+
return this._suggest(word, suggestOptions);
|
|
109
|
+
}
|
|
110
|
+
_suggest(word, suggestOptions) {
|
|
111
|
+
const { numSuggestions = defaultNumSuggestions, numChanges, includeTies, ignoreCase, timeout } = suggestOptions;
|
|
112
|
+
function filter(_word) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
const collector = suggestionCollector(word, clean({
|
|
116
|
+
numSuggestions,
|
|
117
|
+
filter,
|
|
118
|
+
changeLimit: numChanges,
|
|
119
|
+
includeTies,
|
|
120
|
+
ignoreCase,
|
|
121
|
+
timeout,
|
|
122
|
+
weightMap: this.weightMap,
|
|
123
|
+
}));
|
|
124
|
+
this.genSuggestions(collector, suggestOptions);
|
|
125
|
+
return collector.suggestions.map((r) => ({ ...r, word: r.word }));
|
|
126
|
+
}
|
|
127
|
+
genSuggestions(collector, suggestOptions) {
|
|
128
|
+
if (this.options.noSuggest)
|
|
129
|
+
return;
|
|
130
|
+
const _compoundMethod = suggestOptions.compoundMethod ??
|
|
131
|
+
(this.options.useCompounds ? CompoundWordsMethod.JOIN_WORDS : CompoundWordsMethod.NONE);
|
|
132
|
+
wordSuggestFormsArray(collector.word).forEach((w) => this.trie.genSuggestions(impersonateCollector(collector, w), _compoundMethod));
|
|
133
|
+
}
|
|
134
|
+
getErrors() {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
SpellingDictionaryFromTrie.cachedWordsLimit = 50000;
|
|
139
|
+
/**
|
|
140
|
+
* Create a dictionary from a trie file.
|
|
141
|
+
* @param data - contents of a trie file.
|
|
142
|
+
* @param name - name of dictionary
|
|
143
|
+
* @param source - filename or uri
|
|
144
|
+
* @param options - options.
|
|
145
|
+
* @returns SpellingDictionary
|
|
146
|
+
*/
|
|
147
|
+
export function createSpellingDictionaryFromTrieFile(data, name, source, options) {
|
|
148
|
+
data = typeof data === 'string' ? data.split('\n') : data;
|
|
149
|
+
const trieNode = importTrie(data);
|
|
150
|
+
const trie = new Trie(trieNode);
|
|
151
|
+
return new SpellingDictionaryFromTrie(trie, name, options, source);
|
|
152
|
+
}
|
|
153
|
+
function findCache(fn, size = 2000) {
|
|
154
|
+
const cache = createCache01(size);
|
|
155
|
+
function find(word, useCompounds, ignoreCase) {
|
|
156
|
+
const r = cache.get(word);
|
|
157
|
+
if (r !== undefined) {
|
|
158
|
+
if (r.useCompounds === useCompounds && r.ignoreCase === ignoreCase) {
|
|
159
|
+
return r.findResult;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const findResult = fn(word, useCompounds, ignoreCase);
|
|
163
|
+
cache.set(word, { useCompounds, ignoreCase, findResult });
|
|
164
|
+
return findResult;
|
|
165
|
+
}
|
|
166
|
+
return find;
|
|
167
|
+
}
|
|
168
|
+
function outerWordForms(word, mapWord) {
|
|
169
|
+
const forms = pipe([word], opConcatMap((word) => [word, word.normalize('NFC'), word.normalize('NFD')]), opConcatMap((word) => [word, ...mapWord(word)]));
|
|
170
|
+
return new Set(forms);
|
|
171
|
+
}
|
|
172
|
+
export const __testing__ = { outerWordForms };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { DictionaryInformation } from '@cspell/cspell-types';
|
|
2
|
+
import type { SuggestionResult, WeightMap } from 'cspell-trie-lib';
|
|
3
|
+
import type { HasOptions, SearchOptions, SuggestArgs, SuggestOptions } from './SpellingDictionary.mjs';
|
|
4
|
+
export { impersonateCollector, suggestionCollector } from 'cspell-trie-lib';
|
|
5
|
+
export type FilterSuggestionsPredicate = (word: SuggestionResult) => boolean;
|
|
6
|
+
export declare const defaultNumSuggestions = 10;
|
|
7
|
+
declare function wordSearchFormsArray(word: string, isDictionaryCaseSensitive: boolean, ignoreCase: boolean): string[];
|
|
8
|
+
export declare function wordSearchForms(word: string, isDictionaryCaseSensitive: boolean, ignoreCase: boolean): Set<string>;
|
|
9
|
+
export declare function wordSuggestFormsArray(word: string): string[];
|
|
10
|
+
export declare function wordSuggestForms(word: string): Set<string>;
|
|
11
|
+
export declare function hasOptionToSearchOption(opt: HasOptions | undefined): SearchOptions;
|
|
12
|
+
/**
|
|
13
|
+
* Find the canonical form for SearchOptions. Useful Maps and WeakMaps.
|
|
14
|
+
* @param opt - options to normalize
|
|
15
|
+
* @returns SearchOptions - the canonical form
|
|
16
|
+
*/
|
|
17
|
+
export declare function canonicalSearchOptions(opt: SearchOptions): SearchOptions;
|
|
18
|
+
export declare function suggestArgsToSuggestOptions(args: SuggestArgs): SuggestOptions;
|
|
19
|
+
export declare function createWeightMapFromDictionaryInformation(di: undefined): undefined;
|
|
20
|
+
export declare function createWeightMapFromDictionaryInformation(di: DictionaryInformation): WeightMap;
|
|
21
|
+
export declare function createWeightMapFromDictionaryInformation(di: DictionaryInformation | undefined): WeightMap | undefined;
|
|
22
|
+
export declare const __testMethods__: {
|
|
23
|
+
wordSearchForms: typeof wordSearchForms;
|
|
24
|
+
wordSearchFormsArray: typeof wordSearchFormsArray;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=SpellingDictionaryMethods.d.mts.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { mapDictionaryInformationToWeightMap } from 'cspell-trie-lib';
|
|
2
|
+
import { isUpperCase, removeUnboundAccents, ucFirst } from '../util/text.mjs';
|
|
3
|
+
export { impersonateCollector, suggestionCollector } from 'cspell-trie-lib';
|
|
4
|
+
export const defaultNumSuggestions = 10;
|
|
5
|
+
function wordSearchFormsArray(word, isDictionaryCaseSensitive, ignoreCase) {
|
|
6
|
+
return [...wordSearchForms(word, isDictionaryCaseSensitive, ignoreCase)];
|
|
7
|
+
}
|
|
8
|
+
export function wordSearchForms(word, isDictionaryCaseSensitive, ignoreCase) {
|
|
9
|
+
const forms = new Set();
|
|
10
|
+
word = word.normalize('NFC');
|
|
11
|
+
const wordLc = word.toLowerCase();
|
|
12
|
+
if (ignoreCase) {
|
|
13
|
+
if (isDictionaryCaseSensitive) {
|
|
14
|
+
forms.add(wordLc);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
forms.add(wordLc);
|
|
18
|
+
// Legacy remove any unbound accents
|
|
19
|
+
forms.add(removeUnboundAccents(wordLc));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
if (isDictionaryCaseSensitive) {
|
|
24
|
+
forms.add(word);
|
|
25
|
+
forms.add(wordLc);
|
|
26
|
+
// HOUSE -> House, house
|
|
27
|
+
if (isUpperCase(word)) {
|
|
28
|
+
forms.add(ucFirst(wordLc));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
forms.add(wordLc);
|
|
33
|
+
// Legacy remove any unbound accents
|
|
34
|
+
forms.add(removeUnboundAccents(wordLc));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return forms;
|
|
38
|
+
}
|
|
39
|
+
export function wordSuggestFormsArray(word) {
|
|
40
|
+
return [...wordSuggestForms(word)];
|
|
41
|
+
}
|
|
42
|
+
export function wordSuggestForms(word) {
|
|
43
|
+
word = word.normalize('NFC');
|
|
44
|
+
const forms = new Set([word]);
|
|
45
|
+
const wordLc = word.toLowerCase();
|
|
46
|
+
forms.add(wordLc);
|
|
47
|
+
return forms;
|
|
48
|
+
}
|
|
49
|
+
const DEFAULT_HAS_OPTIONS = Object.freeze({});
|
|
50
|
+
export function hasOptionToSearchOption(opt) {
|
|
51
|
+
return canonicalSearchOptions(!opt ? DEFAULT_HAS_OPTIONS : opt);
|
|
52
|
+
}
|
|
53
|
+
const canonicalSearchOptionsMap = new Map();
|
|
54
|
+
const knownCanonicalOptions = new WeakMap();
|
|
55
|
+
/**
|
|
56
|
+
* Find the canonical form for SearchOptions. Useful Maps and WeakMaps.
|
|
57
|
+
* @param opt - options to normalize
|
|
58
|
+
* @returns SearchOptions - the canonical form
|
|
59
|
+
*/
|
|
60
|
+
export function canonicalSearchOptions(opt) {
|
|
61
|
+
const known = knownCanonicalOptions.get(opt);
|
|
62
|
+
if (known)
|
|
63
|
+
return known;
|
|
64
|
+
const { ignoreCase, useCompounds } = opt;
|
|
65
|
+
const foundLevel1Map = canonicalSearchOptionsMap.get(ignoreCase);
|
|
66
|
+
const useLevel1Map = foundLevel1Map || new Map();
|
|
67
|
+
if (!foundLevel1Map) {
|
|
68
|
+
canonicalSearchOptionsMap.set(ignoreCase, useLevel1Map);
|
|
69
|
+
}
|
|
70
|
+
const foundCanOpts = useLevel1Map.get(useCompounds);
|
|
71
|
+
const canOpts = foundCanOpts || Object.freeze({ ignoreCase, useCompounds });
|
|
72
|
+
if (!foundCanOpts) {
|
|
73
|
+
useLevel1Map.set(useCompounds, canOpts);
|
|
74
|
+
}
|
|
75
|
+
knownCanonicalOptions.set(opt, canOpts);
|
|
76
|
+
return canOpts;
|
|
77
|
+
}
|
|
78
|
+
export function suggestArgsToSuggestOptions(args) {
|
|
79
|
+
const [_word, options, compoundMethod, numChanges, ignoreCase] = args;
|
|
80
|
+
const suggestOptions = typeof options === 'object'
|
|
81
|
+
? options
|
|
82
|
+
: {
|
|
83
|
+
numSuggestions: options,
|
|
84
|
+
compoundMethod,
|
|
85
|
+
numChanges,
|
|
86
|
+
ignoreCase,
|
|
87
|
+
};
|
|
88
|
+
return suggestOptions;
|
|
89
|
+
}
|
|
90
|
+
export function createWeightMapFromDictionaryInformation(di) {
|
|
91
|
+
return di ? mapDictionaryInformationToWeightMap(di) : undefined;
|
|
92
|
+
}
|
|
93
|
+
export const __testMethods__ = {
|
|
94
|
+
wordSearchForms,
|
|
95
|
+
wordSearchFormsArray,
|
|
96
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IgnoreCaseOption, SpellingDictionary } from './SpellingDictionary.mjs';
|
|
2
|
+
import { type TypoEntry, type TyposDef } from './Typos/index.mjs';
|
|
3
|
+
export interface SuggestDictionary extends SpellingDictionary {
|
|
4
|
+
/**
|
|
5
|
+
* Determine if the word can appear in a list of suggestions.
|
|
6
|
+
* @param word - word
|
|
7
|
+
* @param ignoreCaseAndAccents - ignore case.
|
|
8
|
+
* @returns true if a word is suggested, otherwise false.
|
|
9
|
+
*/
|
|
10
|
+
isSuggestedWord(word: string, ignoreCaseAndAccents?: IgnoreCaseOption): boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Create a dictionary where all words are to be forbidden.
|
|
14
|
+
* @param entries - list of Typos Entries
|
|
15
|
+
* @param name - name of dictionary
|
|
16
|
+
* @param source - source
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export declare function createSuggestDictionary(entries: readonly string[] | TyposDef | Iterable<TypoEntry>, name: string, source: string): SuggestDictionary;
|
|
20
|
+
//# sourceMappingURL=SuggestDictionary.d.mts.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { pipe } from '@cspell/cspell-pipe/sync';
|
|
2
|
+
import { createAutoResolveWeakCache } from '../util/AutoResolve.mjs';
|
|
3
|
+
import { mapperRemoveCaseAndAccents } from '../util/textMappers.mjs';
|
|
4
|
+
import * as defaults from './defaults.mjs';
|
|
5
|
+
import { processEntriesToTyposDef } from './Typos/index.mjs';
|
|
6
|
+
import { extractAllSuggestions } from './Typos/util.mjs';
|
|
7
|
+
class SuggestDictionaryImpl {
|
|
8
|
+
constructor(name, source, typosDef) {
|
|
9
|
+
this.name = name;
|
|
10
|
+
this.source = source;
|
|
11
|
+
this.typosDef = typosDef;
|
|
12
|
+
this.containsNoSuggestWords = false;
|
|
13
|
+
this.options = {};
|
|
14
|
+
this.type = 'suggest';
|
|
15
|
+
this.isDictionaryCaseSensitive = true;
|
|
16
|
+
this.size = Object.keys(typosDef).length;
|
|
17
|
+
this.suggestions = extractAllSuggestions(typosDef);
|
|
18
|
+
this.suggestionsLower = new Set(pipe(this.suggestions, mapperRemoveCaseAndAccents));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A Forbidden word list does not "have" valid words.
|
|
22
|
+
* Therefore it always returns false.
|
|
23
|
+
* @param _word - the word
|
|
24
|
+
* @param _options - options
|
|
25
|
+
* @returns always false
|
|
26
|
+
*/
|
|
27
|
+
has(_word, _options) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
/** A more detailed search for a word, might take longer than `has` */
|
|
31
|
+
find(_word, _options) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
isForbidden(_word, _ignoreCaseAndAccents) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
isNoSuggestWord(_word, _options) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Determine if the word can appear in a list of suggestions.
|
|
42
|
+
* @param word - word
|
|
43
|
+
* @param ignoreCaseAndAccents - ignore case.
|
|
44
|
+
* @returns true if a word is suggested, otherwise false.
|
|
45
|
+
*/
|
|
46
|
+
isSuggestedWord(word, ignoreCaseAndAccents = defaults.isForbiddenIgnoreCaseAndAccents) {
|
|
47
|
+
if (this.suggestions.has(word))
|
|
48
|
+
return true;
|
|
49
|
+
const lcWord = word.toLowerCase();
|
|
50
|
+
return ignoreCaseAndAccents && (this.suggestions.has(lcWord) || this.suggestionsLower.has(lcWord));
|
|
51
|
+
}
|
|
52
|
+
suggest(word) {
|
|
53
|
+
return this._suggest(word) || this._suggest(word.toLowerCase()) || [];
|
|
54
|
+
}
|
|
55
|
+
_suggest(word) {
|
|
56
|
+
if (!(word in this.typosDef))
|
|
57
|
+
return undefined;
|
|
58
|
+
const sug = this.typosDef[word];
|
|
59
|
+
const isPreferred = true;
|
|
60
|
+
if (!sug)
|
|
61
|
+
return [];
|
|
62
|
+
if (typeof sug === 'string') {
|
|
63
|
+
return [
|
|
64
|
+
{
|
|
65
|
+
word: sug,
|
|
66
|
+
cost: 1,
|
|
67
|
+
isPreferred,
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
return sug.map((word, index) => ({ word, cost: index + 1, isPreferred }));
|
|
72
|
+
}
|
|
73
|
+
genSuggestions(collector) {
|
|
74
|
+
const sugs = this.suggest(collector.word);
|
|
75
|
+
sugs.forEach((result) => collector.add(result));
|
|
76
|
+
}
|
|
77
|
+
mapWord(word) {
|
|
78
|
+
return word;
|
|
79
|
+
}
|
|
80
|
+
getErrors() {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const createCache = createAutoResolveWeakCache();
|
|
85
|
+
/**
|
|
86
|
+
* Create a dictionary where all words are to be forbidden.
|
|
87
|
+
* @param entries - list of Typos Entries
|
|
88
|
+
* @param name - name of dictionary
|
|
89
|
+
* @param source - source
|
|
90
|
+
* @returns
|
|
91
|
+
*/
|
|
92
|
+
export function createSuggestDictionary(entries, name, source) {
|
|
93
|
+
return createCache.get(entries, () => {
|
|
94
|
+
const def = processEntriesToTyposDef(entries);
|
|
95
|
+
return new SuggestDictionaryImpl(name, source, def);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type TermValueTypoNoSuggestions = false;
|
|
2
|
+
type TermValueTypoSingleSuggestion = string;
|
|
3
|
+
type TermValueTypoMultipleSuggestions = string[];
|
|
4
|
+
export type TermValueTypoWithSuggestions = TermValueTypoSingleSuggestion | TermValueTypoMultipleSuggestions;
|
|
5
|
+
export type TermValueTypo = TermValueTypoWithSuggestions | TermValueTypoNoSuggestions;
|
|
6
|
+
export type TermValueIgnoreWord = null;
|
|
7
|
+
export type TermValueOk = true;
|
|
8
|
+
export type TermsDefValue = TermValueTypo | TermValueIgnoreWord | TermValueOk;
|
|
9
|
+
export type TermsDefKey = string;
|
|
10
|
+
export type TermsDef = Record<TermsDefKey, TermsDefValue>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=terms.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TermsDefKey, TermValueTypo, TermValueTypoNoSuggestions, TermValueTypoWithSuggestions } from '../Terms/index.mjs';
|
|
2
|
+
export type TypoValueNoSuggestions = TermValueTypoNoSuggestions;
|
|
3
|
+
export type TypoValueWithSuggestions = TermValueTypoWithSuggestions;
|
|
4
|
+
export type TyposDefValue = TermValueTypo;
|
|
5
|
+
export type TyposDefKey = TermsDefKey;
|
|
6
|
+
/**
|
|
7
|
+
* Typos Definition
|
|
8
|
+
* key - the incorrect word
|
|
9
|
+
* value - the suggestions.
|
|
10
|
+
*/
|
|
11
|
+
export type TyposDef = Record<TyposDefKey, TyposDefValue>;
|
|
12
|
+
type TypoWithNoSuggestions = string;
|
|
13
|
+
type TypoWithSuggestionsArray = [forbidWord: string, ...suggestions: string[]];
|
|
14
|
+
type TypoWithSuggestionsObj = TyposDef;
|
|
15
|
+
type TypoWithSuggestions = TypoWithSuggestionsArray | TypoWithSuggestionsObj;
|
|
16
|
+
export type TypoEntry = TypoWithNoSuggestions | TypoWithSuggestions;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=typos.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { TypoEntry, TyposDef } from './typos.mjs';
|
|
2
|
+
export declare function createTyposDefFromEntries(entries: Iterable<TypoEntry>): TyposDef;
|
|
3
|
+
export declare function sanitizeIntoTypoDef(dirtyDef: TyposDef | Record<string, unknown> | unknown): TyposDef | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Parse Typos Entries
|
|
6
|
+
*
|
|
7
|
+
* Format:
|
|
8
|
+
* - `word:suggestion`
|
|
9
|
+
* - `word->suggestion`
|
|
10
|
+
* - `word: first, second, third suggestions`
|
|
11
|
+
*
|
|
12
|
+
* Note:
|
|
13
|
+
* ```plaintext
|
|
14
|
+
* yellow:blue, green
|
|
15
|
+
* ```
|
|
16
|
+
* Is the same as multiple entries with the same key and different suggestions.
|
|
17
|
+
* ```plaintext
|
|
18
|
+
* yellow:blue
|
|
19
|
+
* yellow:green
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Used to process entries found in a `cspell.json` file.
|
|
23
|
+
* @param entries - entries to process
|
|
24
|
+
* @returns a TyposDef
|
|
25
|
+
*/
|
|
26
|
+
export declare function processEntriesToTyposDef(entries: Iterable<TypoEntry> | TyposDef | Record<string, unknown>): TyposDef;
|
|
27
|
+
/**
|
|
28
|
+
* Tries to parse an entry.
|
|
29
|
+
* @param line - any valid TypoEntry.
|
|
30
|
+
* @returns a valid TypoEntry
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseTyposLine(line: TypoEntry): TypoEntry | undefined;
|
|
33
|
+
export declare function parseTyposFile(content: string): TyposDef;
|
|
34
|
+
//# sourceMappingURL=typosParser.d.mts.map
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import assert from 'assert';
|
|
2
|
+
import { appendToDef, createTyposDef } from './util.mjs';
|
|
3
|
+
function assertString(v) {
|
|
4
|
+
assert(typeof v === 'string', 'A string was expected.');
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
const suggestionsSeparator = /[,]/;
|
|
8
|
+
const typoSuggestionsSeparator = /:|->/;
|
|
9
|
+
const typoEntrySeparator = /[\n;]/;
|
|
10
|
+
const inlineComment = /#.*/gm;
|
|
11
|
+
export function createTyposDefFromEntries(entries) {
|
|
12
|
+
const def = Object.create(null);
|
|
13
|
+
for (const entry of entries) {
|
|
14
|
+
appendToDef(def, entry);
|
|
15
|
+
}
|
|
16
|
+
return def;
|
|
17
|
+
}
|
|
18
|
+
function normalize(s) {
|
|
19
|
+
return s.normalize();
|
|
20
|
+
}
|
|
21
|
+
function trimAndFilter(lines) {
|
|
22
|
+
return lines
|
|
23
|
+
.map((s) => s.trim())
|
|
24
|
+
.filter((s) => !!s)
|
|
25
|
+
.map(normalize);
|
|
26
|
+
}
|
|
27
|
+
function cleanSugs(rawSugs) {
|
|
28
|
+
const sugs = trimAndFilter(rawSugs);
|
|
29
|
+
return sugs.length === 1 ? sugs[0] : sugs.length ? sugs : false;
|
|
30
|
+
}
|
|
31
|
+
function splitSuggestionsValue(value) {
|
|
32
|
+
return cleanSugs(value.split(suggestionsSeparator));
|
|
33
|
+
}
|
|
34
|
+
export function sanitizeIntoTypoDef(dirtyDef) {
|
|
35
|
+
if (!dirtyDef || typeof dirtyDef !== 'object')
|
|
36
|
+
return undefined;
|
|
37
|
+
const def = createTyposDef();
|
|
38
|
+
for (const [rawKey, value] of Object.entries(dirtyDef)) {
|
|
39
|
+
const key = normalize(rawKey.trim());
|
|
40
|
+
if (!key)
|
|
41
|
+
continue;
|
|
42
|
+
if (typeof value === 'string') {
|
|
43
|
+
def[key] = splitSuggestionsValue(value);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (Array.isArray(value)) {
|
|
47
|
+
const sugs = cleanSugs(value.filter(assertString));
|
|
48
|
+
def[key] = sugs;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
assert(value === false, 'Unexpected suggestion type.');
|
|
52
|
+
def[key] = false;
|
|
53
|
+
}
|
|
54
|
+
return def;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Parse Typos Entries
|
|
58
|
+
*
|
|
59
|
+
* Format:
|
|
60
|
+
* - `word:suggestion`
|
|
61
|
+
* - `word->suggestion`
|
|
62
|
+
* - `word: first, second, third suggestions`
|
|
63
|
+
*
|
|
64
|
+
* Note:
|
|
65
|
+
* ```plaintext
|
|
66
|
+
* yellow:blue, green
|
|
67
|
+
* ```
|
|
68
|
+
* Is the same as multiple entries with the same key and different suggestions.
|
|
69
|
+
* ```plaintext
|
|
70
|
+
* yellow:blue
|
|
71
|
+
* yellow:green
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* Used to process entries found in a `cspell.json` file.
|
|
75
|
+
* @param entries - entries to process
|
|
76
|
+
* @returns a TyposDef
|
|
77
|
+
*/
|
|
78
|
+
export function processEntriesToTyposDef(entries) {
|
|
79
|
+
const def = isIterable(entries) ? reduceToTyposDef(entries) : entries;
|
|
80
|
+
const result = sanitizeIntoTypoDef(def);
|
|
81
|
+
assert(result);
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
function reduceToTyposDef(entries) {
|
|
85
|
+
const def = createTyposDef();
|
|
86
|
+
for (const entry of entries) {
|
|
87
|
+
appendToDef(def, parseTyposLine(entry));
|
|
88
|
+
}
|
|
89
|
+
return def;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Tries to parse an entry.
|
|
93
|
+
* @param line - any valid TypoEntry.
|
|
94
|
+
* @returns a valid TypoEntry
|
|
95
|
+
*/
|
|
96
|
+
export function parseTyposLine(line) {
|
|
97
|
+
if (!line)
|
|
98
|
+
return undefined;
|
|
99
|
+
if (typeof line === 'string') {
|
|
100
|
+
const def = createTyposDef();
|
|
101
|
+
for (const subEntry of splitIntoLines(line)) {
|
|
102
|
+
const [left, right] = splitEntry(subEntry);
|
|
103
|
+
const typo = left.trim();
|
|
104
|
+
if (!right)
|
|
105
|
+
return typo;
|
|
106
|
+
const sugs = splitSuggestionsValue(right);
|
|
107
|
+
def[typo] = sugs;
|
|
108
|
+
}
|
|
109
|
+
return def;
|
|
110
|
+
}
|
|
111
|
+
if (Array.isArray(line)) {
|
|
112
|
+
const [key, ...sugs] = line.filter(assertString).map((s) => s.trim());
|
|
113
|
+
if (!key)
|
|
114
|
+
return undefined;
|
|
115
|
+
return [key, ...sugs];
|
|
116
|
+
}
|
|
117
|
+
return sanitizeIntoTypoDef(line);
|
|
118
|
+
}
|
|
119
|
+
function splitIntoLines(content) {
|
|
120
|
+
return trimAndFilter(normalize(content).split(typoEntrySeparator));
|
|
121
|
+
}
|
|
122
|
+
function splitEntry(line) {
|
|
123
|
+
return line.split(typoSuggestionsSeparator, 2);
|
|
124
|
+
}
|
|
125
|
+
export function parseTyposFile(content) {
|
|
126
|
+
const lines = splitIntoLines(content.replace(inlineComment, ''));
|
|
127
|
+
return reduceToTyposDef(lines);
|
|
128
|
+
}
|
|
129
|
+
function isIterable(v) {
|
|
130
|
+
return Symbol.iterator in v;
|
|
131
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { TypoEntry, TyposDef, TyposDefKey, TyposDefValue } from './typos.mjs';
|
|
2
|
+
export declare function mergeDefEntry(targetDef: TyposDef, key: string, value: TyposDefValue): TyposDef;
|
|
3
|
+
/**
|
|
4
|
+
* Merge in place the entries `fromDef` into `targetDef`
|
|
5
|
+
* @param targetDef - the target
|
|
6
|
+
* @param fromDef - the source
|
|
7
|
+
* @returns the target
|
|
8
|
+
*/
|
|
9
|
+
export declare function mergeDef(targetDef: TyposDef, fromDef: TyposDef): TyposDef;
|
|
10
|
+
/**
|
|
11
|
+
* Append an entry to a TyposDef.
|
|
12
|
+
* @param def - modified in place
|
|
13
|
+
* @param entry- entry to add.
|
|
14
|
+
* @returns def
|
|
15
|
+
*/
|
|
16
|
+
export declare function appendToDef(def: TyposDef, entry: TypoEntry | undefined): TyposDef;
|
|
17
|
+
export declare function createTyposDef(entries?: Iterable<[TyposDefKey, TyposDefValue]>): TyposDef;
|
|
18
|
+
/**
|
|
19
|
+
* Extract all suggestions.
|
|
20
|
+
* @param typosDef - the def
|
|
21
|
+
* @returns the set of suggestions.
|
|
22
|
+
*/
|
|
23
|
+
export declare function extractAllSuggestions(typosDef: TyposDef): Set<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Extract all words that have been explicitly ignore because they contains the `ignorePrefix`.
|
|
26
|
+
* @param typosDef - the def
|
|
27
|
+
* @param ignorePrefix - prefix
|
|
28
|
+
* @returns set of ignored words with the prefix removed.
|
|
29
|
+
*/
|
|
30
|
+
export declare function extractIgnoreValues(typosDef: TyposDef, ignorePrefix: string): Set<string>;
|
|
31
|
+
//# sourceMappingURL=util.d.mts.map
|