cspell-dictionary 6.9.0 → 6.10.1
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/ForbiddenWordsDictionary.d.ts +11 -0
- package/dist/SpellingDictionary/ForbiddenWordsDictionary.js +73 -0
- package/dist/SpellingDictionary/SpellingDictionary.d.ts +16 -2
- package/dist/SpellingDictionary/SpellingDictionaryFromTrie.d.ts +9 -1
- package/dist/SpellingDictionary/SpellingDictionaryFromTrie.js +12 -3
- package/dist/SpellingDictionary/createSpellingDictionary.d.ts +12 -5
- package/dist/SpellingDictionary/createSpellingDictionary.js +13 -28
- package/dist/SpellingDictionary/index.d.ts +3 -1
- package/dist/SpellingDictionary/index.js +5 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/package.json +11 -5
- package/dist/SpellingDictionary/Dictionaries.d.ts +0 -9
- package/dist/SpellingDictionary/Dictionaries.js +0 -61
- package/dist/SpellingDictionary/SpellingDictionaryError.d.ts +0 -10
- package/dist/SpellingDictionary/SpellingDictionaryError.js +0 -18
- package/dist/util/Comparable.d.ts +0 -20
- package/dist/util/Comparable.js +0 -55
- package/dist/util/FreqCounter.d.ts +0 -16
- package/dist/util/FreqCounter.js +0 -52
- package/dist/util/Memorizer.d.ts +0 -65
- package/dist/util/Memorizer.js +0 -138
- package/dist/util/MinHeapQueue.d.ts +0 -23
- package/dist/util/MinHeapQueue.js +0 -97
- package/dist/util/PairingHeap.d.ts +0 -32
- package/dist/util/PairingHeap.js +0 -90
- package/dist/util/TextMap.d.ts +0 -15
- package/dist/util/TextMap.js +0 -62
- package/dist/util/TextRange.d.ts +0 -28
- package/dist/util/TextRange.js +0 -144
- package/dist/util/debugPerf.d.ts +0 -9
- package/dist/util/debugPerf.js +0 -22
- package/dist/util/errors.d.ts +0 -17
- package/dist/util/errors.js +0 -52
- package/dist/util/fileReader.d.ts +0 -4
- package/dist/util/fileReader.js +0 -21
- package/dist/util/iterableIteratorLib.d.ts +0 -4
- package/dist/util/iterableIteratorLib.js +0 -14
- package/dist/util/logger.d.ts +0 -33
- package/dist/util/logger.js +0 -46
- package/dist/util/memorizerWeak.d.ts +0 -6
- package/dist/util/memorizerWeak.js +0 -42
- package/dist/util/resolveFile.d.ts +0 -13
- package/dist/util/resolveFile.js +0 -127
- package/dist/util/search.d.ts +0 -6
- package/dist/util/search.js +0 -23
- package/dist/util/textRegex.d.ts +0 -1
- package/dist/util/textRegex.js +0 -2
- package/dist/util/timer.d.ts +0 -26
- package/dist/util/timer.js +0 -58
- package/dist/util/util.test copy.d.ts +0 -2
- package/dist/util/util.test copy.js +0 -17
- package/dist/util/wordSplitter.d.ts +0 -46
- package/dist/util/wordSplitter.js +0 -326
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SpellingDictionary } from './SpellingDictionary';
|
|
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
|
|
9
|
+
*/
|
|
10
|
+
export declare function createForbiddenWordsDictionary(wordList: readonly string[], name: string, source: string): SpellingDictionary;
|
|
11
|
+
//# sourceMappingURL=ForbiddenWordsDictionary.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createForbiddenWordsDictionary = void 0;
|
|
4
|
+
const cspell_trie_lib_1 = require("cspell-trie-lib");
|
|
5
|
+
const SpellingDictionaryFromTrie_1 = require("./SpellingDictionaryFromTrie");
|
|
6
|
+
const createSpellingDictionary_1 = require("./createSpellingDictionary");
|
|
7
|
+
class ForbiddenWordsDictionary {
|
|
8
|
+
constructor(name, source, wordList) {
|
|
9
|
+
this.name = name;
|
|
10
|
+
this.source = source;
|
|
11
|
+
this.containsNoSuggestWords = false;
|
|
12
|
+
this.options = {};
|
|
13
|
+
this.type = 'forbidden';
|
|
14
|
+
this.isDictionaryCaseSensitive = true;
|
|
15
|
+
const words = (0, cspell_trie_lib_1.parseDictionaryLines)(wordList, { stripCaseAndAccents: false });
|
|
16
|
+
const trie = (0, cspell_trie_lib_1.buildTrieFast)(words);
|
|
17
|
+
this.dict = new SpellingDictionaryFromTrie_1.SpellingDictionaryFromTrie(trie, name, createSpellingDictionary_1.defaultOptions, source);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A Forbidden word list does not "have" valid words.
|
|
21
|
+
* Therefore it always returns false.
|
|
22
|
+
* @param _word - the word
|
|
23
|
+
* @param _options - options
|
|
24
|
+
* @returns always false
|
|
25
|
+
*/
|
|
26
|
+
has(_word, _options) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
/** A more detailed search for a word, might take longer than `has` */
|
|
30
|
+
find(word, options) {
|
|
31
|
+
const r = this.dict.find(word, options);
|
|
32
|
+
if (!r || r.found === false || r.forbidden)
|
|
33
|
+
return undefined;
|
|
34
|
+
return { ...r, forbidden: true };
|
|
35
|
+
}
|
|
36
|
+
isForbidden(word) {
|
|
37
|
+
const r = this.find(word);
|
|
38
|
+
if (!r)
|
|
39
|
+
return false;
|
|
40
|
+
return r.forbidden && r.found !== false;
|
|
41
|
+
}
|
|
42
|
+
isNoSuggestWord(_word, _options) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
suggest() {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
genSuggestions() {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
mapWord(word) {
|
|
52
|
+
return word;
|
|
53
|
+
}
|
|
54
|
+
get size() {
|
|
55
|
+
return this.dict.size;
|
|
56
|
+
}
|
|
57
|
+
getErrors() {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create a dictionary where all words are to be forbidden.
|
|
63
|
+
* @param wordList - list of words
|
|
64
|
+
* @param name
|
|
65
|
+
* @param source
|
|
66
|
+
* @param options
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
function createForbiddenWordsDictionary(wordList, name, source) {
|
|
70
|
+
return new ForbiddenWordsDictionary(name, source, wordList);
|
|
71
|
+
}
|
|
72
|
+
exports.createForbiddenWordsDictionary = createForbiddenWordsDictionary;
|
|
73
|
+
//# sourceMappingURL=ForbiddenWordsDictionary.js.map
|
|
@@ -47,13 +47,18 @@ export interface FindResult {
|
|
|
47
47
|
export declare type HasOptions = SearchOptions;
|
|
48
48
|
export interface SpellingDictionaryOptions {
|
|
49
49
|
repMap?: ReplaceMap;
|
|
50
|
-
useCompounds?: boolean;
|
|
51
50
|
/**
|
|
52
51
|
* The dictionary is case aware.
|
|
53
52
|
*/
|
|
54
53
|
caseSensitive?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* This is a NO Suggest dictionary used for words to be ignored.
|
|
56
|
+
*/
|
|
55
57
|
noSuggest?: boolean;
|
|
56
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Extra dictionary information used in improving suggestions
|
|
60
|
+
* based upon locale.
|
|
61
|
+
*/
|
|
57
62
|
dictionaryInformation?: DictionaryInformation;
|
|
58
63
|
/**
|
|
59
64
|
* Strip Case and Accents to allow for case insensitive searches and
|
|
@@ -65,6 +70,15 @@ export interface SpellingDictionaryOptions {
|
|
|
65
70
|
* @default true
|
|
66
71
|
*/
|
|
67
72
|
supportNonStrictSearches?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Turns on legacy word compounds.
|
|
75
|
+
* @deprecated
|
|
76
|
+
*/
|
|
77
|
+
useCompounds?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Optional WeightMap used to improve suggestions.
|
|
80
|
+
*/
|
|
81
|
+
weightMap?: WeightMap | undefined;
|
|
68
82
|
}
|
|
69
83
|
export interface DictionaryInfo {
|
|
70
84
|
/** The name of the dictionary */
|
|
@@ -32,5 +32,13 @@ export declare class SpellingDictionaryFromTrie implements SpellingDictionary {
|
|
|
32
32
|
genSuggestions(collector: SuggestionCollector, suggestOptions: SuggestOptions): void;
|
|
33
33
|
getErrors(): Error[];
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Create a dictionary from a trie file.
|
|
37
|
+
* @param data - contents of a trie file.
|
|
38
|
+
* @param name - name of dictionary
|
|
39
|
+
* @param source - filename or uri
|
|
40
|
+
* @param options - options.
|
|
41
|
+
* @returns SpellingDictionary
|
|
42
|
+
*/
|
|
43
|
+
export declare function createSpellingDictionaryFromTrieFile(data: Iterable<string> | string, name: string, source: string, options: SpellingDictionaryOptions): SpellingDictionary;
|
|
36
44
|
//# sourceMappingURL=SpellingDictionaryFromTrie.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createSpellingDictionaryFromTrieFile = exports.SpellingDictionaryFromTrie = void 0;
|
|
4
4
|
const cspell_trie_lib_1 = require("cspell-trie-lib");
|
|
5
5
|
const repMap_1 = require("../util/repMap");
|
|
6
6
|
const clean_1 = require("../util/clean");
|
|
@@ -139,10 +139,19 @@ class SpellingDictionaryFromTrie {
|
|
|
139
139
|
}
|
|
140
140
|
exports.SpellingDictionaryFromTrie = SpellingDictionaryFromTrie;
|
|
141
141
|
SpellingDictionaryFromTrie.cachedWordsLimit = 50000;
|
|
142
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Create a dictionary from a trie file.
|
|
144
|
+
* @param data - contents of a trie file.
|
|
145
|
+
* @param name - name of dictionary
|
|
146
|
+
* @param source - filename or uri
|
|
147
|
+
* @param options - options.
|
|
148
|
+
* @returns SpellingDictionary
|
|
149
|
+
*/
|
|
150
|
+
function createSpellingDictionaryFromTrieFile(data, name, source, options) {
|
|
151
|
+
data = typeof data === 'string' ? data.split('\n') : data;
|
|
143
152
|
const trieNode = (0, cspell_trie_lib_1.importTrie)(data);
|
|
144
153
|
const trie = new cspell_trie_lib_1.Trie(trieNode);
|
|
145
154
|
return new SpellingDictionaryFromTrie(trie, name, options, source);
|
|
146
155
|
}
|
|
147
|
-
exports.
|
|
156
|
+
exports.createSpellingDictionaryFromTrieFile = createSpellingDictionaryFromTrieFile;
|
|
148
157
|
//# sourceMappingURL=SpellingDictionaryFromTrie.js.map
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { IterableLike } from '../util/IterableLike';
|
|
2
|
-
import { SpellingDictionary, SpellingDictionaryOptions
|
|
3
|
-
export declare
|
|
4
|
-
|
|
2
|
+
import type { DictionaryInfo, SpellingDictionary, SpellingDictionaryOptions } from './SpellingDictionary';
|
|
3
|
+
export declare const defaultOptions: SpellingDictionaryOptions;
|
|
4
|
+
/**
|
|
5
|
+
* Create a SpellingDictionary
|
|
6
|
+
* @param wordList - list of words
|
|
7
|
+
* @param name - name of dictionary
|
|
8
|
+
* @param source - filename or uri
|
|
9
|
+
* @param options - dictionary options
|
|
10
|
+
* @returns a Spelling Dictionary
|
|
11
|
+
*/
|
|
12
|
+
export declare function createSpellingDictionary(wordList: readonly string[] | IterableLike<string>, name: string, source: string, options?: SpellingDictionaryOptions | undefined): SpellingDictionary;
|
|
5
13
|
export interface SpellingDictionaryLoadError extends Error {
|
|
6
14
|
/** The Error Name */
|
|
7
15
|
readonly name: string;
|
|
@@ -12,6 +20,5 @@ export interface SpellingDictionaryLoadError extends Error {
|
|
|
12
20
|
/** Dictionary Information */
|
|
13
21
|
readonly info: DictionaryInfo;
|
|
14
22
|
}
|
|
15
|
-
export declare function createFailedToLoadDictionary(error:
|
|
16
|
-
export declare function createSpellingDictionaryLoadError(errorName: string, message: string, info: DictionaryInfo, cause?: Error): SpellingDictionaryLoadError;
|
|
23
|
+
export declare function createFailedToLoadDictionary(name: string, source: string, error: Error, options?: SpellingDictionaryOptions | undefined): SpellingDictionary;
|
|
17
24
|
//# sourceMappingURL=createSpellingDictionary.d.ts.map
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createFailedToLoadDictionary = exports.createSpellingDictionary = exports.defaultOptions = void 0;
|
|
4
4
|
const cspell_trie_lib_1 = require("cspell-trie-lib");
|
|
5
5
|
const fast_equals_1 = require("fast-equals");
|
|
6
|
-
const gensequence_1 = require("gensequence");
|
|
7
6
|
const simpleCache_1 = require("../util/simpleCache");
|
|
8
7
|
const SpellingDictionaryFromTrie_1 = require("./SpellingDictionaryFromTrie");
|
|
9
8
|
const SpellingDictionaryMethods_1 = require("./SpellingDictionaryMethods");
|
|
10
|
-
|
|
9
|
+
exports.defaultOptions = Object.freeze({
|
|
11
10
|
weightMap: undefined,
|
|
12
11
|
});
|
|
13
12
|
const cachedDictionaries = new simpleCache_1.AutoWeakCache(_createSpellingDictionary, 64);
|
|
14
13
|
const maxSetSize = 3;
|
|
15
14
|
const cachedParamsByWordList = new simpleCache_1.SimpleCache(64);
|
|
15
|
+
/**
|
|
16
|
+
* Create a SpellingDictionary
|
|
17
|
+
* @param wordList - list of words
|
|
18
|
+
* @param name - name of dictionary
|
|
19
|
+
* @param source - filename or uri
|
|
20
|
+
* @param options - dictionary options
|
|
21
|
+
* @returns a Spelling Dictionary
|
|
22
|
+
*/
|
|
16
23
|
function createSpellingDictionary(wordList, name, source, options) {
|
|
17
24
|
const params = [wordList, name, source, options];
|
|
18
25
|
if (!Array.isArray(wordList)) {
|
|
@@ -37,24 +44,14 @@ function _createSpellingDictionary(params) {
|
|
|
37
44
|
const parseOptions = { stripCaseAndAccents: options?.supportNonStrictSearches ?? true };
|
|
38
45
|
const words = (0, cspell_trie_lib_1.parseDictionaryLines)(wordList, parseOptions);
|
|
39
46
|
const trie = (0, cspell_trie_lib_1.buildTrieFast)(words);
|
|
40
|
-
const opts = { ...(options || defaultOptions) };
|
|
47
|
+
const opts = { ...(options || exports.defaultOptions) };
|
|
41
48
|
if (opts.weightMap === undefined && opts.dictionaryInformation) {
|
|
42
49
|
opts.weightMap = (0, SpellingDictionaryMethods_1.createWeightMapFromDictionaryInformation)(opts.dictionaryInformation);
|
|
43
50
|
}
|
|
44
51
|
return new SpellingDictionaryFromTrie_1.SpellingDictionaryFromTrie(trie, name, opts, source);
|
|
45
52
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
const words = (0, cspell_trie_lib_1.parseDictionaryLines)(wordList.concat(wordList.map((a) => a.toLowerCase())), {
|
|
49
|
-
stripCaseAndAccents: !options?.noSuggest,
|
|
50
|
-
});
|
|
51
|
-
const forbidWords = gensequence_1.operators.map((w) => '!' + w)(words);
|
|
52
|
-
const trie = (0, cspell_trie_lib_1.buildTrieFast)(forbidWords);
|
|
53
|
-
return new SpellingDictionaryFromTrie_1.SpellingDictionaryFromTrie(trie, name, options || defaultOptions, source);
|
|
54
|
-
}
|
|
55
|
-
exports.createForbiddenWordsDictionary = createForbiddenWordsDictionary;
|
|
56
|
-
function createFailedToLoadDictionary(error) {
|
|
57
|
-
const { name, source, options } = error.info;
|
|
53
|
+
function createFailedToLoadDictionary(name, source, error, options) {
|
|
54
|
+
options = options || {};
|
|
58
55
|
return {
|
|
59
56
|
name,
|
|
60
57
|
source,
|
|
@@ -76,16 +73,4 @@ function createFailedToLoadDictionary(error) {
|
|
|
76
73
|
};
|
|
77
74
|
}
|
|
78
75
|
exports.createFailedToLoadDictionary = createFailedToLoadDictionary;
|
|
79
|
-
function createSpellingDictionaryLoadError(errorName, message, info, cause) {
|
|
80
|
-
const err = {
|
|
81
|
-
name: errorName,
|
|
82
|
-
message,
|
|
83
|
-
info,
|
|
84
|
-
cause,
|
|
85
|
-
};
|
|
86
|
-
const stack = cause?.stack;
|
|
87
|
-
stack && (err.stack = stack);
|
|
88
|
-
return err;
|
|
89
|
-
}
|
|
90
|
-
exports.createSpellingDictionaryLoadError = createSpellingDictionaryLoadError;
|
|
91
76
|
//# sourceMappingURL=createSpellingDictionary.js.map
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createSpellingDictionary } from './createSpellingDictionary';
|
|
2
|
+
export { createForbiddenWordsDictionary } from './ForbiddenWordsDictionary';
|
|
2
3
|
export type { FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary';
|
|
3
4
|
export { createCollection } from './SpellingDictionaryCollection';
|
|
5
|
+
export { createSpellingDictionaryFromTrieFile } from './SpellingDictionaryFromTrie';
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createSpellingDictionaryFromTrieFile = exports.createCollection = exports.createForbiddenWordsDictionary = exports.createSpellingDictionary = void 0;
|
|
4
4
|
var createSpellingDictionary_1 = require("./createSpellingDictionary");
|
|
5
|
-
Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return createSpellingDictionary_1.createForbiddenWordsDictionary; } });
|
|
6
5
|
Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return createSpellingDictionary_1.createSpellingDictionary; } });
|
|
6
|
+
var ForbiddenWordsDictionary_1 = require("./ForbiddenWordsDictionary");
|
|
7
|
+
Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return ForbiddenWordsDictionary_1.createForbiddenWordsDictionary; } });
|
|
7
8
|
var SpellingDictionaryCollection_1 = require("./SpellingDictionaryCollection");
|
|
8
9
|
Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return SpellingDictionaryCollection_1.createCollection; } });
|
|
10
|
+
var SpellingDictionaryFromTrie_1 = require("./SpellingDictionaryFromTrie");
|
|
11
|
+
Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return SpellingDictionaryFromTrie_1.createSpellingDictionaryFromTrieFile; } });
|
|
9
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { createCollection, createForbiddenWordsDictionary, createSpellingDictionary } from './SpellingDictionary';
|
|
1
|
+
export { createCollection, createForbiddenWordsDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, } from './SpellingDictionary';
|
|
2
2
|
export type { FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createSpellingDictionary = exports.createForbiddenWordsDictionary = exports.createCollection = void 0;
|
|
3
|
+
exports.createSpellingDictionaryFromTrieFile = exports.createSpellingDictionary = exports.createForbiddenWordsDictionary = exports.createCollection = void 0;
|
|
4
4
|
var SpellingDictionary_1 = require("./SpellingDictionary");
|
|
5
5
|
Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return SpellingDictionary_1.createCollection; } });
|
|
6
6
|
Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createForbiddenWordsDictionary; } });
|
|
7
7
|
Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createSpellingDictionary; } });
|
|
8
|
+
Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return SpellingDictionary_1.createSpellingDictionaryFromTrieFile; } });
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell-dictionary",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.1",
|
|
4
4
|
"description": "A spelling dictionary library useful for checking words and getting suggestions.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -37,11 +37,17 @@
|
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=14"
|
|
39
39
|
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/jest": "^29.0.3",
|
|
42
|
+
"jest": "^29.0.3",
|
|
43
|
+
"ts-jest": "^29.0.1"
|
|
44
|
+
},
|
|
40
45
|
"dependencies": {
|
|
41
|
-
"@cspell/cspell-pipe": "
|
|
42
|
-
"@cspell/cspell-types": "
|
|
43
|
-
"cspell-trie-lib": "
|
|
46
|
+
"@cspell/cspell-pipe": "^6.10.1",
|
|
47
|
+
"@cspell/cspell-types": "^6.10.1",
|
|
48
|
+
"cspell-trie-lib": "^6.10.1",
|
|
44
49
|
"fast-equals": "^4.0.3",
|
|
45
50
|
"gensequence": "^4.0.2"
|
|
46
|
-
}
|
|
51
|
+
},
|
|
52
|
+
"gitHead": "03625a3f7ca4ef85f3549ccae73d90d2cd3ac0f0"
|
|
47
53
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CSpellSettingsInternal, DictionaryDefinitionInternal } from '../Models/CSpellSettingsInternalDef';
|
|
2
|
-
import { SpellingDictionary } from './SpellingDictionary';
|
|
3
|
-
import { SpellingDictionaryCollection } from './SpellingDictionaryCollection';
|
|
4
|
-
export declare function loadDictionaryDefs(defsToLoad: DictionaryDefinitionInternal[]): Promise<SpellingDictionary>[];
|
|
5
|
-
export declare function loadDictionaryDefsSync(defsToLoad: DictionaryDefinitionInternal[]): SpellingDictionary[];
|
|
6
|
-
export declare function refreshDictionaryCache(maxAge?: number): Promise<void>;
|
|
7
|
-
export declare function getDictionaryInternal(settings: CSpellSettingsInternal): Promise<SpellingDictionaryCollection>;
|
|
8
|
-
export declare function getDictionaryInternalSync(settings: CSpellSettingsInternal): SpellingDictionaryCollection;
|
|
9
|
-
//# sourceMappingURL=Dictionaries.d.ts.map
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDictionaryInternalSync = exports.getDictionaryInternal = exports.refreshDictionaryCache = exports.loadDictionaryDefsSync = exports.loadDictionaryDefs = void 0;
|
|
4
|
-
const DictionarySettings_1 = require("../Settings/DictionarySettings");
|
|
5
|
-
const util_1 = require("../util/util");
|
|
6
|
-
const createSpellingDictionary_1 = require("./createSpellingDictionary");
|
|
7
|
-
const DictionaryLoader_1 = require("./DictionaryLoader");
|
|
8
|
-
const SpellingDictionaryCollection_1 = require("./SpellingDictionaryCollection");
|
|
9
|
-
function loadDictionaryDefs(defsToLoad) {
|
|
10
|
-
return defsToLoad.map(DictionaryLoader_1.loadDictionary);
|
|
11
|
-
}
|
|
12
|
-
exports.loadDictionaryDefs = loadDictionaryDefs;
|
|
13
|
-
function loadDictionaryDefsSync(defsToLoad) {
|
|
14
|
-
return defsToLoad.map(DictionaryLoader_1.loadDictionarySync);
|
|
15
|
-
}
|
|
16
|
-
exports.loadDictionaryDefsSync = loadDictionaryDefsSync;
|
|
17
|
-
function refreshDictionaryCache(maxAge) {
|
|
18
|
-
return (0, DictionaryLoader_1.refreshCacheEntries)(maxAge);
|
|
19
|
-
}
|
|
20
|
-
exports.refreshDictionaryCache = refreshDictionaryCache;
|
|
21
|
-
const emptyWords = Object.freeze([]);
|
|
22
|
-
async function getDictionaryInternal(settings) {
|
|
23
|
-
const spellDictionaries = await Promise.all(loadDictionaryDefs((0, DictionarySettings_1.calcDictionaryDefsToLoad)(settings)));
|
|
24
|
-
return _getDictionaryInternal(settings, spellDictionaries);
|
|
25
|
-
}
|
|
26
|
-
exports.getDictionaryInternal = getDictionaryInternal;
|
|
27
|
-
function getDictionaryInternalSync(settings) {
|
|
28
|
-
const spellDictionaries = loadDictionaryDefsSync((0, DictionarySettings_1.calcDictionaryDefsToLoad)(settings));
|
|
29
|
-
return _getDictionaryInternal(settings, spellDictionaries);
|
|
30
|
-
}
|
|
31
|
-
exports.getDictionaryInternalSync = getDictionaryInternalSync;
|
|
32
|
-
function _getDictionaryInternal(settings, spellDictionaries) {
|
|
33
|
-
const { words = emptyWords, userWords = emptyWords, flagWords = emptyWords, ignoreWords = emptyWords } = settings;
|
|
34
|
-
const settingsWordsDictionary = (0, createSpellingDictionary_1.createSpellingDictionary)(words, '[words]', 'From Settings `words`', {
|
|
35
|
-
caseSensitive: true,
|
|
36
|
-
weightMap: undefined,
|
|
37
|
-
});
|
|
38
|
-
const settingsUserWordsDictionary = userWords.length
|
|
39
|
-
? (0, createSpellingDictionary_1.createSpellingDictionary)(userWords, '[userWords]', 'From Settings `userWords`', {
|
|
40
|
-
caseSensitive: true,
|
|
41
|
-
weightMap: undefined,
|
|
42
|
-
})
|
|
43
|
-
: undefined;
|
|
44
|
-
const ignoreWordsDictionary = (0, createSpellingDictionary_1.createSpellingDictionary)(ignoreWords, '[ignoreWords]', 'From Settings `ignoreWords`', {
|
|
45
|
-
caseSensitive: true,
|
|
46
|
-
noSuggest: true,
|
|
47
|
-
weightMap: undefined,
|
|
48
|
-
});
|
|
49
|
-
const flagWordsDictionary = (0, createSpellingDictionary_1.createForbiddenWordsDictionary)(flagWords, '[flagWords]', 'From Settings `flagWords`', {
|
|
50
|
-
weightMap: undefined,
|
|
51
|
-
});
|
|
52
|
-
const dictionaries = [
|
|
53
|
-
...spellDictionaries,
|
|
54
|
-
settingsWordsDictionary,
|
|
55
|
-
settingsUserWordsDictionary,
|
|
56
|
-
ignoreWordsDictionary,
|
|
57
|
-
flagWordsDictionary,
|
|
58
|
-
].filter(util_1.isDefined);
|
|
59
|
-
return (0, SpellingDictionaryCollection_1.createCollection)(dictionaries, 'dictionary collection');
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=Dictionaries.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { LoadOptions } from './DictionaryLoader';
|
|
2
|
-
export declare class SpellingDictionaryLoadError extends Error {
|
|
3
|
-
readonly uri: string;
|
|
4
|
-
readonly options: LoadOptions;
|
|
5
|
-
readonly cause: Error;
|
|
6
|
-
readonly name: string;
|
|
7
|
-
constructor(uri: string, options: LoadOptions, cause: Error, message: string);
|
|
8
|
-
}
|
|
9
|
-
export declare function isSpellingDictionaryLoadError(e: Error): e is SpellingDictionaryLoadError;
|
|
10
|
-
//# sourceMappingURL=SpellingDictionaryError.d.ts.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSpellingDictionaryLoadError = exports.SpellingDictionaryLoadError = void 0;
|
|
4
|
-
class SpellingDictionaryLoadError extends Error {
|
|
5
|
-
constructor(uri, options, cause, message) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.uri = uri;
|
|
8
|
-
this.options = options;
|
|
9
|
-
this.cause = cause;
|
|
10
|
-
this.name = options.name;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.SpellingDictionaryLoadError = SpellingDictionaryLoadError;
|
|
14
|
-
function isSpellingDictionaryLoadError(e) {
|
|
15
|
-
return e instanceof SpellingDictionaryLoadError;
|
|
16
|
-
}
|
|
17
|
-
exports.isSpellingDictionaryLoadError = isSpellingDictionaryLoadError;
|
|
18
|
-
//# sourceMappingURL=SpellingDictionaryError.js.map
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare type Comparable = number | string | boolean | undefined | null | Date;
|
|
2
|
-
export declare type ComparableFilter<T> = T extends Comparable ? T : never;
|
|
3
|
-
export declare type ComparablePropertyNames<T> = {
|
|
4
|
-
[K in keyof T]: T[K] extends Comparable ? K : never;
|
|
5
|
-
}[keyof T];
|
|
6
|
-
export declare type ComparableProperties<T> = Pick<T, ComparablePropertyNames<T>>;
|
|
7
|
-
export declare type CompareArg<T> = ComparablePropertyNames<T> | ((t: T) => Comparable);
|
|
8
|
-
export declare type CompareFn<T> = (a: T, b: T) => number;
|
|
9
|
-
export declare function compareBy<T>(extract: CompareArg<T>, ...extractors: CompareArg<T>[]): CompareFn<T>;
|
|
10
|
-
export declare function compareBy<T>(extract: CompareArg<T>): CompareFn<T>;
|
|
11
|
-
export declare function compareBy<T>(extract1: CompareArg<T>, extract2: CompareArg<T>): CompareFn<T>;
|
|
12
|
-
export declare function compareBy<T>(extract1: CompareArg<T>, extract2: CompareArg<T>, extract3: CompareArg<T>): CompareFn<T>;
|
|
13
|
-
export declare function compareByRev<T>(extract: CompareArg<T>, ...extractors: CompareArg<T>[]): CompareFn<T>;
|
|
14
|
-
export declare function compareByRev<T>(extract: CompareArg<T>): CompareFn<T>;
|
|
15
|
-
export declare function compareByRev<T>(extract1: CompareArg<T>, extract2: CompareArg<T>): CompareFn<T>;
|
|
16
|
-
export declare function compareByRev<T>(extract1: CompareArg<T>, extract2: CompareArg<T>, extract3: CompareArg<T>): CompareFn<T>;
|
|
17
|
-
export declare function compareEach<T>(...compareFn: CompareFn<T>[]): CompareFn<T>;
|
|
18
|
-
export declare function compare<T>(a: ComparableFilter<T>, b: ComparableFilter<T>): number;
|
|
19
|
-
export declare function reverse<T>(fn: CompareFn<T>): CompareFn<T>;
|
|
20
|
-
//# sourceMappingURL=Comparable.d.ts.map
|
package/dist/util/Comparable.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reverse = exports.compare = exports.compareEach = exports.compareByRev = exports.compareBy = void 0;
|
|
4
|
-
function compareBy(extract, ...extractors) {
|
|
5
|
-
const compareFns = [extract, ...extractors]
|
|
6
|
-
.map((ex) => (typeof ex === 'function' ? ex : (t) => t[ex]))
|
|
7
|
-
.map((ex) => (a, b) => _compare(ex(a), ex(b)));
|
|
8
|
-
return compareEach(...compareFns);
|
|
9
|
-
}
|
|
10
|
-
exports.compareBy = compareBy;
|
|
11
|
-
function compareByRev(extract, ...extractors) {
|
|
12
|
-
return reverse(compareBy(extract, ...extractors));
|
|
13
|
-
}
|
|
14
|
-
exports.compareByRev = compareByRev;
|
|
15
|
-
function compareEach(...compareFn) {
|
|
16
|
-
return (a, b) => {
|
|
17
|
-
for (const fn of compareFn) {
|
|
18
|
-
const r = fn(a, b);
|
|
19
|
-
if (r) {
|
|
20
|
-
return r;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return 0;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
exports.compareEach = compareEach;
|
|
27
|
-
function _compare(a, b) {
|
|
28
|
-
if (a === b)
|
|
29
|
-
return 0;
|
|
30
|
-
if (a === undefined)
|
|
31
|
-
return 1;
|
|
32
|
-
if (b === undefined)
|
|
33
|
-
return -1;
|
|
34
|
-
if (a === null)
|
|
35
|
-
return 1;
|
|
36
|
-
if (b === null)
|
|
37
|
-
return -1;
|
|
38
|
-
if (a < b)
|
|
39
|
-
return -1;
|
|
40
|
-
if (a > b)
|
|
41
|
-
return 1;
|
|
42
|
-
return 0;
|
|
43
|
-
}
|
|
44
|
-
function compare(a, b) {
|
|
45
|
-
return _compare(a, b);
|
|
46
|
-
}
|
|
47
|
-
exports.compare = compare;
|
|
48
|
-
function reverse(fn) {
|
|
49
|
-
return (a, b) => {
|
|
50
|
-
const r = fn(a, b);
|
|
51
|
-
return r ? -r : 0;
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
exports.reverse = reverse;
|
|
55
|
-
//# sourceMappingURL=Comparable.js.map
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { IterableLike } from './IterableLike';
|
|
2
|
-
export declare class FreqCounter<T> {
|
|
3
|
-
private _total;
|
|
4
|
-
readonly _counters: Map<T, number>;
|
|
5
|
-
get total(): number;
|
|
6
|
-
get counters(): Map<T, number>;
|
|
7
|
-
getCount(key: T): number | undefined;
|
|
8
|
-
getFreq(key: T): number;
|
|
9
|
-
addKeyCount(key: T, count: number): this;
|
|
10
|
-
addKey(key: T): this;
|
|
11
|
-
addKeys(keys: IterableLike<T>): void;
|
|
12
|
-
addKeyCounts(values: IterableLike<[T, number]>): void;
|
|
13
|
-
merge(...freqCounters: FreqCounter<T>[]): FreqCounter<T>;
|
|
14
|
-
static create<T>(values?: IterableLike<T>): FreqCounter<T>;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=FreqCounter.d.ts.map
|
package/dist/util/FreqCounter.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FreqCounter = void 0;
|
|
4
|
-
class FreqCounter {
|
|
5
|
-
constructor() {
|
|
6
|
-
this._total = 0;
|
|
7
|
-
this._counters = new Map();
|
|
8
|
-
}
|
|
9
|
-
get total() {
|
|
10
|
-
return this._total;
|
|
11
|
-
}
|
|
12
|
-
get counters() {
|
|
13
|
-
return this._counters;
|
|
14
|
-
}
|
|
15
|
-
getCount(key) {
|
|
16
|
-
return this._counters.get(key);
|
|
17
|
-
}
|
|
18
|
-
getFreq(key) {
|
|
19
|
-
return (this.getCount(key) || 0) / (this._total || 1);
|
|
20
|
-
}
|
|
21
|
-
addKeyCount(key, count) {
|
|
22
|
-
this._total += count;
|
|
23
|
-
this._counters.set(key, (this._counters.get(key) || 0) + count);
|
|
24
|
-
return this;
|
|
25
|
-
}
|
|
26
|
-
addKey(key) {
|
|
27
|
-
return this.addKeyCount(key, 1);
|
|
28
|
-
}
|
|
29
|
-
addKeys(keys) {
|
|
30
|
-
for (const key of keys) {
|
|
31
|
-
this.addKey(key);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
addKeyCounts(values) {
|
|
35
|
-
for (const pair of values) {
|
|
36
|
-
this.addKeyCount(pair[0], pair[1]);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
merge(...freqCounters) {
|
|
40
|
-
for (const fc of freqCounters) {
|
|
41
|
-
this.addKeyCounts(fc._counters);
|
|
42
|
-
}
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
static create(values) {
|
|
46
|
-
const fc = new FreqCounter();
|
|
47
|
-
fc.addKeys(values || []);
|
|
48
|
-
return fc;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.FreqCounter = FreqCounter;
|
|
52
|
-
//# sourceMappingURL=FreqCounter.js.map
|