cspell-dictionary 6.28.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}/SpellingDictionaryCollection.d.ts +1 -1
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionaryCollection.js +12 -12
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionaryFromTrie.d.ts +1 -1
- package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionaryFromTrie.js +16 -16
- 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/{util → cjs/util}/repMap.js +4 -4
- 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 +27 -18
- package/dist/SpellingDictionary/Typos/index.d.ts +0 -4
- package/dist/SpellingDictionary/createInlineSpellingDictionary.js +0 -25
- /package/dist/{SpellingDictionary → cjs/SpellingDictionary}/SpellingDictionary.d.ts +0 -0
- /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}/repMap.d.ts +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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IterableLike } from '../util/IterableLike';
|
|
2
|
-
import type { DictionaryInfo, SpellingDictionary, SpellingDictionaryOptions } from './SpellingDictionary';
|
|
1
|
+
import type { IterableLike } from '../util/IterableLike.js';
|
|
2
|
+
import type { DictionaryInfo, SpellingDictionary, SpellingDictionaryOptions } from './SpellingDictionary.js';
|
|
3
3
|
/**
|
|
4
4
|
* Create a SpellingDictionary
|
|
5
5
|
* @param wordList - list of words
|
|
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createFailedToLoadDictionary = exports.createSpellingDictionary = void 0;
|
|
4
4
|
const cspell_trie_lib_1 = require("cspell-trie-lib");
|
|
5
5
|
const fast_equals_1 = require("fast-equals");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const cachedDictionaries = new
|
|
6
|
+
const simpleCache_js_1 = require("../util/simpleCache.js");
|
|
7
|
+
const SpellingDictionary_js_1 = require("./SpellingDictionary.js");
|
|
8
|
+
const SpellingDictionaryFromTrie_js_1 = require("./SpellingDictionaryFromTrie.js");
|
|
9
|
+
const SpellingDictionaryMethods_js_1 = require("./SpellingDictionaryMethods.js");
|
|
10
|
+
const cachedDictionaries = new simpleCache_js_1.AutoWeakCache(_createSpellingDictionary, 64);
|
|
11
11
|
const maxSetSize = 3;
|
|
12
|
-
const cachedParamsByWordList = new
|
|
12
|
+
const cachedParamsByWordList = new simpleCache_js_1.SimpleCache(64);
|
|
13
13
|
/**
|
|
14
14
|
* Create a SpellingDictionary
|
|
15
15
|
* @param wordList - list of words
|
|
@@ -42,11 +42,11 @@ function _createSpellingDictionary(params) {
|
|
|
42
42
|
const parseOptions = { stripCaseAndAccents: options?.supportNonStrictSearches ?? true };
|
|
43
43
|
const words = (0, cspell_trie_lib_1.parseDictionaryLines)(wordList, parseOptions);
|
|
44
44
|
const trie = (0, cspell_trie_lib_1.buildTrieFast)(words);
|
|
45
|
-
const opts = { ...(options ||
|
|
45
|
+
const opts = { ...(options || SpellingDictionary_js_1.defaultOptions) };
|
|
46
46
|
if (opts.weightMap === undefined && opts.dictionaryInformation) {
|
|
47
|
-
opts.weightMap = (0,
|
|
47
|
+
opts.weightMap = (0, SpellingDictionaryMethods_js_1.createWeightMapFromDictionaryInformation)(opts.dictionaryInformation);
|
|
48
48
|
}
|
|
49
|
-
return new
|
|
49
|
+
return new SpellingDictionaryFromTrie_js_1.SpellingDictionaryFromTrie(trie, name, opts, source);
|
|
50
50
|
}
|
|
51
51
|
function createFailedToLoadDictionary(name, source, error, options) {
|
|
52
52
|
options = options || {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { CachingDictionary, createCachingDictionary } from './CachingDictionary';
|
|
2
|
-
export { createInlineSpellingDictionary } from './createInlineSpellingDictionary';
|
|
3
|
-
export { createFailedToLoadDictionary, createSpellingDictionary } from './createSpellingDictionary';
|
|
4
|
-
export { createFlagWordsDictionary, createFlagWordsDictionary as createForbiddenWordsDictionary, } from './FlagWordsDictionary';
|
|
5
|
-
export { createIgnoreWordsDictionary } from './IgnoreWordsDictionary';
|
|
6
|
-
export type { DictionaryDefinitionInline, FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary';
|
|
7
|
-
export { createCollection, SpellingDictionaryCollection } from './SpellingDictionaryCollection';
|
|
8
|
-
export { createSpellingDictionaryFromTrieFile } from './SpellingDictionaryFromTrie';
|
|
9
|
-
export { createSuggestDictionary } from './SuggestDictionary';
|
|
10
|
-
export { createTyposDictionary } from './TyposDictionary';
|
|
1
|
+
export { CachingDictionary, createCachingDictionary } from './CachingDictionary.js';
|
|
2
|
+
export { createInlineSpellingDictionary } from './createInlineSpellingDictionary.js';
|
|
3
|
+
export { createFailedToLoadDictionary, createSpellingDictionary } from './createSpellingDictionary.js';
|
|
4
|
+
export { createFlagWordsDictionary, createFlagWordsDictionary as createForbiddenWordsDictionary, } from './FlagWordsDictionary.js';
|
|
5
|
+
export { createIgnoreWordsDictionary } from './IgnoreWordsDictionary.js';
|
|
6
|
+
export type { DictionaryDefinitionInline, FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary.js';
|
|
7
|
+
export { createCollection, SpellingDictionaryCollection } from './SpellingDictionaryCollection.js';
|
|
8
|
+
export { createSpellingDictionaryFromTrieFile } from './SpellingDictionaryFromTrie.js';
|
|
9
|
+
export { createSuggestDictionary } from './SuggestDictionary.js';
|
|
10
|
+
export { createTyposDictionary } from './TyposDictionary.js';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createTyposDictionary = exports.createSuggestDictionary = exports.createSpellingDictionaryFromTrieFile = exports.createCollection = exports.createIgnoreWordsDictionary = exports.createForbiddenWordsDictionary = exports.createFlagWordsDictionary = exports.createSpellingDictionary = exports.createFailedToLoadDictionary = exports.createInlineSpellingDictionary = exports.createCachingDictionary = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "createCachingDictionary", { enumerable: true, get: function () { return
|
|
6
|
-
var
|
|
7
|
-
Object.defineProperty(exports, "createInlineSpellingDictionary", { enumerable: true, get: function () { return
|
|
8
|
-
var
|
|
9
|
-
Object.defineProperty(exports, "createFailedToLoadDictionary", { enumerable: true, get: function () { return
|
|
10
|
-
Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return
|
|
11
|
-
var
|
|
12
|
-
Object.defineProperty(exports, "createFlagWordsDictionary", { enumerable: true, get: function () { return
|
|
13
|
-
Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return
|
|
14
|
-
var
|
|
15
|
-
Object.defineProperty(exports, "createIgnoreWordsDictionary", { enumerable: true, get: function () { return
|
|
16
|
-
var
|
|
17
|
-
Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return
|
|
18
|
-
var
|
|
19
|
-
Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return
|
|
20
|
-
var
|
|
21
|
-
Object.defineProperty(exports, "createSuggestDictionary", { enumerable: true, get: function () { return
|
|
22
|
-
var
|
|
23
|
-
Object.defineProperty(exports, "createTyposDictionary", { enumerable: true, get: function () { return
|
|
4
|
+
var CachingDictionary_js_1 = require("./CachingDictionary.js");
|
|
5
|
+
Object.defineProperty(exports, "createCachingDictionary", { enumerable: true, get: function () { return CachingDictionary_js_1.createCachingDictionary; } });
|
|
6
|
+
var createInlineSpellingDictionary_js_1 = require("./createInlineSpellingDictionary.js");
|
|
7
|
+
Object.defineProperty(exports, "createInlineSpellingDictionary", { enumerable: true, get: function () { return createInlineSpellingDictionary_js_1.createInlineSpellingDictionary; } });
|
|
8
|
+
var createSpellingDictionary_js_1 = require("./createSpellingDictionary.js");
|
|
9
|
+
Object.defineProperty(exports, "createFailedToLoadDictionary", { enumerable: true, get: function () { return createSpellingDictionary_js_1.createFailedToLoadDictionary; } });
|
|
10
|
+
Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return createSpellingDictionary_js_1.createSpellingDictionary; } });
|
|
11
|
+
var FlagWordsDictionary_js_1 = require("./FlagWordsDictionary.js");
|
|
12
|
+
Object.defineProperty(exports, "createFlagWordsDictionary", { enumerable: true, get: function () { return FlagWordsDictionary_js_1.createFlagWordsDictionary; } });
|
|
13
|
+
Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return FlagWordsDictionary_js_1.createFlagWordsDictionary; } });
|
|
14
|
+
var IgnoreWordsDictionary_js_1 = require("./IgnoreWordsDictionary.js");
|
|
15
|
+
Object.defineProperty(exports, "createIgnoreWordsDictionary", { enumerable: true, get: function () { return IgnoreWordsDictionary_js_1.createIgnoreWordsDictionary; } });
|
|
16
|
+
var SpellingDictionaryCollection_js_1 = require("./SpellingDictionaryCollection.js");
|
|
17
|
+
Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return SpellingDictionaryCollection_js_1.createCollection; } });
|
|
18
|
+
var SpellingDictionaryFromTrie_js_1 = require("./SpellingDictionaryFromTrie.js");
|
|
19
|
+
Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return SpellingDictionaryFromTrie_js_1.createSpellingDictionaryFromTrieFile; } });
|
|
20
|
+
var SuggestDictionary_js_1 = require("./SuggestDictionary.js");
|
|
21
|
+
Object.defineProperty(exports, "createSuggestDictionary", { enumerable: true, get: function () { return SuggestDictionary_js_1.createSuggestDictionary; } });
|
|
22
|
+
var TyposDictionary_js_1 = require("./TyposDictionary.js");
|
|
23
|
+
Object.defineProperty(exports, "createTyposDictionary", { enumerable: true, get: function () { return TyposDictionary_js_1.createTyposDictionary; } });
|
|
24
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { CachingDictionary, FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryCollection, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary';
|
|
2
|
-
export { createCachingDictionary, createCollection, createFailedToLoadDictionary, createFlagWordsDictionary, createForbiddenWordsDictionary, createIgnoreWordsDictionary, createInlineSpellingDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, createSuggestDictionary, } from './SpellingDictionary';
|
|
1
|
+
export type { CachingDictionary, FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryCollection, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary/index.js';
|
|
2
|
+
export { createCachingDictionary, createCollection, createFailedToLoadDictionary, createFlagWordsDictionary, createForbiddenWordsDictionary, createIgnoreWordsDictionary, createInlineSpellingDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, createSuggestDictionary, } from './SpellingDictionary/index.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createSuggestDictionary = exports.createSpellingDictionaryFromTrieFile = exports.createSpellingDictionary = exports.createInlineSpellingDictionary = exports.createIgnoreWordsDictionary = exports.createForbiddenWordsDictionary = exports.createFlagWordsDictionary = exports.createFailedToLoadDictionary = exports.createCollection = exports.createCachingDictionary = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "createCachingDictionary", { enumerable: true, get: function () { return
|
|
6
|
-
Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return
|
|
7
|
-
Object.defineProperty(exports, "createFailedToLoadDictionary", { enumerable: true, get: function () { return
|
|
8
|
-
Object.defineProperty(exports, "createFlagWordsDictionary", { enumerable: true, get: function () { return
|
|
9
|
-
Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return
|
|
10
|
-
Object.defineProperty(exports, "createIgnoreWordsDictionary", { enumerable: true, get: function () { return
|
|
11
|
-
Object.defineProperty(exports, "createInlineSpellingDictionary", { enumerable: true, get: function () { return
|
|
12
|
-
Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return
|
|
13
|
-
Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return
|
|
14
|
-
Object.defineProperty(exports, "createSuggestDictionary", { enumerable: true, get: function () { return
|
|
4
|
+
var index_js_1 = require("./SpellingDictionary/index.js");
|
|
5
|
+
Object.defineProperty(exports, "createCachingDictionary", { enumerable: true, get: function () { return index_js_1.createCachingDictionary; } });
|
|
6
|
+
Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return index_js_1.createCollection; } });
|
|
7
|
+
Object.defineProperty(exports, "createFailedToLoadDictionary", { enumerable: true, get: function () { return index_js_1.createFailedToLoadDictionary; } });
|
|
8
|
+
Object.defineProperty(exports, "createFlagWordsDictionary", { enumerable: true, get: function () { return index_js_1.createFlagWordsDictionary; } });
|
|
9
|
+
Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return index_js_1.createForbiddenWordsDictionary; } });
|
|
10
|
+
Object.defineProperty(exports, "createIgnoreWordsDictionary", { enumerable: true, get: function () { return index_js_1.createIgnoreWordsDictionary; } });
|
|
11
|
+
Object.defineProperty(exports, "createInlineSpellingDictionary", { enumerable: true, get: function () { return index_js_1.createInlineSpellingDictionary; } });
|
|
12
|
+
Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return index_js_1.createSpellingDictionary; } });
|
|
13
|
+
Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return index_js_1.createSpellingDictionaryFromTrieFile; } });
|
|
14
|
+
Object.defineProperty(exports, "createSuggestDictionary", { enumerable: true, get: function () { return index_js_1.createSuggestDictionary; } });
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.__testing__ = exports.createRepMapper = exports.createMapper = void 0;
|
|
4
4
|
const cspell_trie_lib_1 = require("cspell-trie-lib");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const regexHelper_js_1 = require("./regexHelper.js");
|
|
6
|
+
const util_js_1 = require("./util.js");
|
|
7
7
|
function createMapper(repMap, ignoreCharset) {
|
|
8
8
|
if (!repMap && !ignoreCharset)
|
|
9
9
|
return (a) => a;
|
|
@@ -62,7 +62,7 @@ function createMapperRegExp(repMap) {
|
|
|
62
62
|
s = r;
|
|
63
63
|
}
|
|
64
64
|
catch (err) {
|
|
65
|
-
return (0,
|
|
65
|
+
return (0, regexHelper_js_1.escapeRegEx)(s);
|
|
66
66
|
}
|
|
67
67
|
return s;
|
|
68
68
|
})
|
|
@@ -130,7 +130,7 @@ function calcAllEdits(root, word) {
|
|
|
130
130
|
return edits;
|
|
131
131
|
}
|
|
132
132
|
function createTrie(repMap, ignoreCharset) {
|
|
133
|
-
const combined = [repMap, charsetToRepMap(ignoreCharset)].filter(
|
|
133
|
+
const combined = [repMap, charsetToRepMap(ignoreCharset)].filter(util_js_1.isDefined).flatMap((a) => a);
|
|
134
134
|
const expanded = expandReplaceMap(combined);
|
|
135
135
|
const trieRoot = Object.create(null);
|
|
136
136
|
expanded.forEach(([match, replaceWith]) => addToTrie(trieRoot, match, replaceWith));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mapperRemoveCaseAndAccents = exports.mapperNormalizeNFC = void 0;
|
|
4
|
-
const
|
|
4
|
+
const text_js_1 = require("./text.js");
|
|
5
5
|
function* mapperNormalizeNFC(words) {
|
|
6
6
|
for (const word of words) {
|
|
7
7
|
yield word.normalize('NFC');
|
|
@@ -12,7 +12,7 @@ function* mapperRemoveCaseAndAccents(words) {
|
|
|
12
12
|
for (const word of words) {
|
|
13
13
|
const lc = word.toLowerCase();
|
|
14
14
|
yield lc;
|
|
15
|
-
const woAccents = (0,
|
|
15
|
+
const woAccents = (0, text_js_1.removeAccents)(lc);
|
|
16
16
|
if (lc !== woAccents)
|
|
17
17
|
yield woAccents;
|
|
18
18
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CacheStats } from '../util/AutoCache.mjs';
|
|
2
|
+
import type { SearchOptions, SpellingDictionary } from './SpellingDictionary.mjs';
|
|
3
|
+
import type { SpellingDictionaryCollection } from './SpellingDictionaryCollection.mjs';
|
|
4
|
+
interface CallStats {
|
|
5
|
+
name: string;
|
|
6
|
+
id: number;
|
|
7
|
+
has: CacheStats;
|
|
8
|
+
isNoSuggestWord: CacheStats;
|
|
9
|
+
isForbidden: CacheStats;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Caching Dictionary remembers method calls to increase performance.
|
|
13
|
+
*/
|
|
14
|
+
export interface CachingDictionary {
|
|
15
|
+
name: string;
|
|
16
|
+
id: number;
|
|
17
|
+
has(word: string): boolean;
|
|
18
|
+
isNoSuggestWord(word: string): boolean;
|
|
19
|
+
isForbidden(word: string): boolean;
|
|
20
|
+
stats(): CallStats;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* create a caching dictionary
|
|
24
|
+
* @param dict - Dictionary to cache the search results.
|
|
25
|
+
* @param options - Search options to use.
|
|
26
|
+
* @returns CachingDictionary
|
|
27
|
+
*/
|
|
28
|
+
export declare function createCachingDictionary(dict: SpellingDictionary | SpellingDictionaryCollection, options: SearchOptions): CachingDictionary;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=CachingDictionary.d.mts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { autoCache, extractStats } from '../util/AutoCache.mjs';
|
|
2
|
+
import { canonicalSearchOptions } from './SpellingDictionaryMethods.mjs';
|
|
3
|
+
let dictionaryCounter = 0;
|
|
4
|
+
class CachedDict {
|
|
5
|
+
constructor(dict, options) {
|
|
6
|
+
this.dict = dict;
|
|
7
|
+
this.options = options;
|
|
8
|
+
this.id = ++dictionaryCounter;
|
|
9
|
+
this.has = autoCache((word) => this.dict.has(word, this.options));
|
|
10
|
+
this.isNoSuggestWord = autoCache((word) => this.dict.isNoSuggestWord(word, this.options));
|
|
11
|
+
this.isForbidden = autoCache((word) => this.dict.isForbidden(word));
|
|
12
|
+
this.name = dict.name;
|
|
13
|
+
// console.log(`CachedDict for ${this.name}`);
|
|
14
|
+
}
|
|
15
|
+
stats() {
|
|
16
|
+
return {
|
|
17
|
+
name: this.name,
|
|
18
|
+
id: this.id,
|
|
19
|
+
has: extractStats(this.has),
|
|
20
|
+
isNoSuggestWord: extractStats(this.isNoSuggestWord),
|
|
21
|
+
isForbidden: extractStats(this.isForbidden),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const knownDicts = new Map();
|
|
26
|
+
/**
|
|
27
|
+
* create a caching dictionary
|
|
28
|
+
* @param dict - Dictionary to cache the search results.
|
|
29
|
+
* @param options - Search options to use.
|
|
30
|
+
* @returns CachingDictionary
|
|
31
|
+
*/
|
|
32
|
+
export function createCachingDictionary(dict, options) {
|
|
33
|
+
options = canonicalSearchOptions(options);
|
|
34
|
+
let knownOptions = knownDicts.get(options);
|
|
35
|
+
if (!knownOptions) {
|
|
36
|
+
knownOptions = new WeakMap();
|
|
37
|
+
knownDicts.set(options, knownOptions);
|
|
38
|
+
}
|
|
39
|
+
const known = knownOptions.get(dict);
|
|
40
|
+
if (known)
|
|
41
|
+
return known;
|
|
42
|
+
const cached = new CachedDict(dict, options);
|
|
43
|
+
knownOptions.set(dict, cached);
|
|
44
|
+
return cached;
|
|
45
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SpellingDictionary } from './SpellingDictionary.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Create a dictionary where all words are to be forbidden.
|
|
4
|
+
* @param wordList - list of words
|
|
5
|
+
* @param name
|
|
6
|
+
* @param source
|
|
7
|
+
* @param options
|
|
8
|
+
* @returns SpellingDictionary
|
|
9
|
+
*/
|
|
10
|
+
export declare function createFlagWordsDictionary(wordList: readonly string[], name: string, source: string): SpellingDictionary;
|
|
11
|
+
//# sourceMappingURL=FlagWordsDictionary.d.mts.map
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { opMap, pipe } from '@cspell/cspell-pipe/sync';
|
|
2
|
+
import { buildTrieFast, parseDictionaryLines } from 'cspell-trie-lib';
|
|
3
|
+
import { createAutoResolveWeakCache } from '../util/AutoResolve.mjs';
|
|
4
|
+
import * as Defaults from './defaults.mjs';
|
|
5
|
+
import { defaultOptions } from './SpellingDictionary.mjs';
|
|
6
|
+
import { SpellingDictionaryFromTrie } from './SpellingDictionaryFromTrie.mjs';
|
|
7
|
+
import { suggestArgsToSuggestOptions } from './SpellingDictionaryMethods.mjs';
|
|
8
|
+
import { createTyposDictionary } from './TyposDictionary.mjs';
|
|
9
|
+
class FlagWordsDictionaryTrie extends SpellingDictionaryFromTrie {
|
|
10
|
+
constructor(trie, name, source) {
|
|
11
|
+
super(trie, name, defaultOptions, source);
|
|
12
|
+
this.name = name;
|
|
13
|
+
this.source = source;
|
|
14
|
+
this.containsNoSuggestWords = false;
|
|
15
|
+
this.options = {};
|
|
16
|
+
this.isDictionaryCaseSensitive = true;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A Forbidden word list does not "have" valid words.
|
|
20
|
+
* Therefore it always returns false.
|
|
21
|
+
* @param _word - the word
|
|
22
|
+
* @param _options - options
|
|
23
|
+
* @returns always false
|
|
24
|
+
*/
|
|
25
|
+
has(_word, _options) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
find(word, hasOptions) {
|
|
29
|
+
const f = super.find(word, hasOptions);
|
|
30
|
+
if (!f || !f.forbidden)
|
|
31
|
+
return undefined;
|
|
32
|
+
return f;
|
|
33
|
+
}
|
|
34
|
+
suggest() {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
genSuggestions() {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
class FlagWordsDictionary {
|
|
42
|
+
constructor(name, source, dictTypos, dictTrie) {
|
|
43
|
+
this.name = name;
|
|
44
|
+
this.source = source;
|
|
45
|
+
this.dictTypos = dictTypos;
|
|
46
|
+
this.dictTrie = dictTrie;
|
|
47
|
+
this.containsNoSuggestWords = false;
|
|
48
|
+
this.options = {};
|
|
49
|
+
this.type = 'flag-words';
|
|
50
|
+
this.isDictionaryCaseSensitive = true;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A Forbidden word list does not "have" valid words.
|
|
54
|
+
* Therefore it always returns false.
|
|
55
|
+
* @param word - the word
|
|
56
|
+
* @param options - options
|
|
57
|
+
* @returns always false
|
|
58
|
+
*/
|
|
59
|
+
has(word, options) {
|
|
60
|
+
return this.dictTypos.has(word, options) || this.dictTrie?.has(word, options) || false;
|
|
61
|
+
}
|
|
62
|
+
/** A more detailed search for a word, might take longer than `has` */
|
|
63
|
+
find(word, options) {
|
|
64
|
+
const findTypos = this.dictTypos.find(word, options);
|
|
65
|
+
if (findTypos)
|
|
66
|
+
return findTypos;
|
|
67
|
+
const ignoreCase = options?.ignoreCase ?? Defaults.ignoreCase;
|
|
68
|
+
if (this.dictTypos.isSuggestedWord(word, ignoreCase))
|
|
69
|
+
return undefined;
|
|
70
|
+
return this.dictTrie?.find(word, options);
|
|
71
|
+
}
|
|
72
|
+
isForbidden(word, ignoreCaseAndAccents = Defaults.isForbiddenIgnoreCaseAndAccents) {
|
|
73
|
+
const findResult = this.find(word, { ignoreCase: ignoreCaseAndAccents });
|
|
74
|
+
return findResult?.forbidden || false;
|
|
75
|
+
}
|
|
76
|
+
isNoSuggestWord(word, options) {
|
|
77
|
+
return this.dictTrie?.isNoSuggestWord(word, options) || this.dictTypos.isNoSuggestWord(word, options);
|
|
78
|
+
}
|
|
79
|
+
suggest(...args) {
|
|
80
|
+
const [word] = args;
|
|
81
|
+
const suggestOptions = suggestArgsToSuggestOptions(args);
|
|
82
|
+
return this.dictTypos.suggest(word, suggestOptions);
|
|
83
|
+
}
|
|
84
|
+
genSuggestions() {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
mapWord(word) {
|
|
88
|
+
return word;
|
|
89
|
+
}
|
|
90
|
+
get size() {
|
|
91
|
+
return this.dictTypos.size + (this.dictTrie?.size || 0);
|
|
92
|
+
}
|
|
93
|
+
getErrors() {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const createCache = createAutoResolveWeakCache();
|
|
98
|
+
/**
|
|
99
|
+
* Create a dictionary where all words are to be forbidden.
|
|
100
|
+
* @param wordList - list of words
|
|
101
|
+
* @param name
|
|
102
|
+
* @param source
|
|
103
|
+
* @param options
|
|
104
|
+
* @returns SpellingDictionary
|
|
105
|
+
*/
|
|
106
|
+
export function createFlagWordsDictionary(wordList, name, source) {
|
|
107
|
+
return createCache.get(wordList, () => {
|
|
108
|
+
const testSpecialCharacters = /[~*+]/;
|
|
109
|
+
const { t: specialWords, f: typoWords } = bisect(parseDictionaryLines(wordList, { stripCaseAndAccents: false }), (line) => testSpecialCharacters.test(line));
|
|
110
|
+
const trieDict = specialWords.size ? buildTrieDict(specialWords, name, source) : undefined;
|
|
111
|
+
const typosDict = createTyposDictionary(typoWords, name, source);
|
|
112
|
+
if (!trieDict)
|
|
113
|
+
return typosDict;
|
|
114
|
+
return new FlagWordsDictionary(name, source, typosDict, trieDict);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
const regExpCleanIgnore = /^(!!)+/;
|
|
118
|
+
function buildTrieDict(words, name, source) {
|
|
119
|
+
const trie = buildTrieFast(pipe(words, opMap((w) => '!' + w), opMap((w) => w.replace(regExpCleanIgnore, ''))));
|
|
120
|
+
return new FlagWordsDictionaryTrie(trie, name, source);
|
|
121
|
+
}
|
|
122
|
+
function bisect(values, predicate) {
|
|
123
|
+
const t = new Set();
|
|
124
|
+
const f = new Set();
|
|
125
|
+
for (const v of values) {
|
|
126
|
+
if (predicate(v)) {
|
|
127
|
+
t.add(v);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
f.add(v);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return { t, f };
|
|
134
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SpellingDictionary } from './SpellingDictionary.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Create a dictionary where all words are to be ignored.
|
|
4
|
+
* Ignored words override forbidden words.
|
|
5
|
+
* @param wordList - list of words
|
|
6
|
+
* @param name - name of dictionary
|
|
7
|
+
* @param source - dictionary source
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function createIgnoreWordsDictionary(wordList: readonly string[], name: string, source: string): SpellingDictionary;
|
|
11
|
+
//# sourceMappingURL=IgnoreWordsDictionary.d.mts.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { opFilter, opMap, pipe } from '@cspell/cspell-pipe/sync';
|
|
2
|
+
import { parseDictionaryLines } from 'cspell-trie-lib';
|
|
3
|
+
import { createAutoResolveWeakCache } from '../util/AutoResolve.mjs';
|
|
4
|
+
import { createSpellingDictionary } from './createSpellingDictionary.mjs';
|
|
5
|
+
import * as Defaults from './defaults.mjs';
|
|
6
|
+
const NormalizeForm = 'NFC';
|
|
7
|
+
class IgnoreWordsDictionary {
|
|
8
|
+
constructor(name, source, words) {
|
|
9
|
+
this.name = name;
|
|
10
|
+
this.source = source;
|
|
11
|
+
this.containsNoSuggestWords = true;
|
|
12
|
+
this.options = {};
|
|
13
|
+
this.type = 'ignore';
|
|
14
|
+
this.isDictionaryCaseSensitive = true;
|
|
15
|
+
this.dict = new Set(words);
|
|
16
|
+
this.dictNonStrict = new Set(pipe(this.dict, opFilter((w) => w.startsWith('~')), opMap((w) => w.slice(1))));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A Forbidden word list does not "have" valid words.
|
|
20
|
+
* Therefore it always returns false.
|
|
21
|
+
* @param _word - the word
|
|
22
|
+
* @param _options - options
|
|
23
|
+
* @returns always false
|
|
24
|
+
*/
|
|
25
|
+
has(word, options) {
|
|
26
|
+
const nWord = word.normalize(NormalizeForm);
|
|
27
|
+
if (this.dict.has(nWord))
|
|
28
|
+
return true;
|
|
29
|
+
const lcWord = nWord.toLowerCase();
|
|
30
|
+
if (this.dict.has(lcWord))
|
|
31
|
+
return true;
|
|
32
|
+
const ignoreCase = options?.ignoreCase ?? Defaults.ignoreCase;
|
|
33
|
+
return ignoreCase && (this.dictNonStrict.has(nWord) || this.dictNonStrict.has(lcWord));
|
|
34
|
+
}
|
|
35
|
+
/** A more detailed search for a word, might take longer than `has` */
|
|
36
|
+
find(word, options) {
|
|
37
|
+
const nWord = word.normalize(NormalizeForm);
|
|
38
|
+
if (this.dict.has(nWord))
|
|
39
|
+
return { found: nWord, forbidden: false, noSuggest: true };
|
|
40
|
+
const lcWord = nWord.toLowerCase();
|
|
41
|
+
if (this.dict.has(lcWord))
|
|
42
|
+
return { found: lcWord, forbidden: false, noSuggest: true };
|
|
43
|
+
const ignoreCase = options?.ignoreCase ?? Defaults.ignoreCase;
|
|
44
|
+
if (!ignoreCase)
|
|
45
|
+
return undefined;
|
|
46
|
+
if (this.dictNonStrict.has(nWord))
|
|
47
|
+
return { found: nWord, forbidden: false, noSuggest: true };
|
|
48
|
+
return (this.dictNonStrict.has(lcWord) && { found: lcWord, forbidden: false, noSuggest: true }) || undefined;
|
|
49
|
+
}
|
|
50
|
+
isForbidden(_word, _ignoreCase) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
isNoSuggestWord(word, options) {
|
|
54
|
+
return this.has(word, options);
|
|
55
|
+
}
|
|
56
|
+
suggest() {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
genSuggestions() {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
mapWord(word) {
|
|
63
|
+
return word;
|
|
64
|
+
}
|
|
65
|
+
get size() {
|
|
66
|
+
return this.dict.size;
|
|
67
|
+
}
|
|
68
|
+
getErrors() {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const createCache = createAutoResolveWeakCache();
|
|
73
|
+
/**
|
|
74
|
+
* Create a dictionary where all words are to be ignored.
|
|
75
|
+
* Ignored words override forbidden words.
|
|
76
|
+
* @param wordList - list of words
|
|
77
|
+
* @param name - name of dictionary
|
|
78
|
+
* @param source - dictionary source
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
81
|
+
export function createIgnoreWordsDictionary(wordList, name, source) {
|
|
82
|
+
return createCache.get(wordList, () => {
|
|
83
|
+
const testSpecialCharacters = /[*+]/;
|
|
84
|
+
const words = [...parseDictionaryLines(wordList, { stripCaseAndAccents: true })].map((w) => w.normalize(NormalizeForm));
|
|
85
|
+
const hasSpecial = words.findIndex((word) => testSpecialCharacters.test(word)) >= 0;
|
|
86
|
+
if (hasSpecial) {
|
|
87
|
+
return createSpellingDictionary(words, name, source, {
|
|
88
|
+
caseSensitive: true,
|
|
89
|
+
noSuggest: true,
|
|
90
|
+
weightMap: undefined,
|
|
91
|
+
supportNonStrictSearches: true,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return new IgnoreWordsDictionary(name, source, words);
|
|
95
|
+
});
|
|
96
|
+
}
|