cspell-trie-lib 5.12.4 → 5.13.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/lib/suggest.js +8 -4
- package/dist/lib/util.d.ts +1 -1
- package/dist/lib/util.js +1 -1
- package/package.json +5 -5
package/dist/lib/suggest.js
CHANGED
|
@@ -12,6 +12,7 @@ const postSwapCost = swapCost - baseCost;
|
|
|
12
12
|
const insertSpaceCost = -1;
|
|
13
13
|
const mapSubCost = 1;
|
|
14
14
|
const maxCostScale = 0.5;
|
|
15
|
+
const discourageInsertCost = baseCost;
|
|
15
16
|
const setOfSeparators = new Set([walker_1.JOIN_SEPARATOR, walker_1.WORD_SEPARATOR]);
|
|
16
17
|
function suggest(root, word, options = {}) {
|
|
17
18
|
const opts = (0, genSuggestionsOptions_1.createSuggestionOptions)(options);
|
|
@@ -45,10 +46,13 @@ function* genCompoundableSuggestions(root, word, options = {}) {
|
|
|
45
46
|
const stack = [];
|
|
46
47
|
const x = ' ' + word;
|
|
47
48
|
const mx = x.length - 1;
|
|
48
|
-
const
|
|
49
|
+
const specialInsCosts = Object.assign(Object.create(null), {
|
|
49
50
|
[walker_1.WORD_SEPARATOR]: insertSpaceCost,
|
|
50
51
|
[walker_1.JOIN_SEPARATOR]: insertSpaceCost,
|
|
51
|
-
};
|
|
52
|
+
});
|
|
53
|
+
const specialSubCosts = Object.assign(Object.create(null), {
|
|
54
|
+
'-': discourageInsertCost,
|
|
55
|
+
});
|
|
52
56
|
let stopNow = false;
|
|
53
57
|
let costLimit = bc * Math.min(word.length * maxCostScale, changeLimit);
|
|
54
58
|
function updateCostLimit(maxCost) {
|
|
@@ -114,8 +118,8 @@ function* genCompoundableSuggestions(root, word, options = {}) {
|
|
|
114
118
|
}
|
|
115
119
|
const d = depth + 1;
|
|
116
120
|
const lastSugLetter = d > 1 ? text[d - 2] : '';
|
|
117
|
-
const c = bc - d;
|
|
118
|
-
const ci = c + (
|
|
121
|
+
const c = bc - d + (specialSubCosts[w] || 0);
|
|
122
|
+
const ci = c + (specialInsCosts[w] || 0);
|
|
119
123
|
// Setup first column
|
|
120
124
|
matrix[d] = matrix[d] || [];
|
|
121
125
|
matrix[d][a] = matrix[d - 1][a] + ci + d - a;
|
package/dist/lib/util.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export declare const normalizeWord: (text: string) => string;
|
|
|
43
43
|
* converts text to lower case and removes any accents.
|
|
44
44
|
* @param text - text to convert
|
|
45
45
|
* @returns lowercase word without accents
|
|
46
|
-
* @deprecated
|
|
46
|
+
* @deprecated true
|
|
47
47
|
*/
|
|
48
48
|
export declare const normalizeWordToLowercase: (text: string) => string;
|
|
49
49
|
/**
|
package/dist/lib/util.js
CHANGED
|
@@ -202,7 +202,7 @@ exports.normalizeWord = normalizeWord;
|
|
|
202
202
|
* converts text to lower case and removes any accents.
|
|
203
203
|
* @param text - text to convert
|
|
204
204
|
* @returns lowercase word without accents
|
|
205
|
-
* @deprecated
|
|
205
|
+
* @deprecated true
|
|
206
206
|
*/
|
|
207
207
|
const normalizeWordToLowercase = (text) => text.toLowerCase().normalize('NFD').replace(/\p{M}/gu, '');
|
|
208
208
|
exports.normalizeWordToLowercase = normalizeWordToLowercase;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell-trie-lib",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.13.1",
|
|
4
4
|
"description": "Trie Data Structure to support cspell.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"node": ">=12.13.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@cspell/dict-en_us": "^2.1.
|
|
47
|
-
"@cspell/dict-es-es": "^2.0
|
|
46
|
+
"@cspell/dict-en_us": "^2.1.4",
|
|
47
|
+
"@cspell/dict-es-es": "^2.1.0",
|
|
48
48
|
"@types/fs-extra": "^9.0.13",
|
|
49
|
-
"@types/node": "^16.11.
|
|
49
|
+
"@types/node": "^16.11.10",
|
|
50
50
|
"jest": "^27.3.1",
|
|
51
51
|
"rimraf": "^3.0.2"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "575e5e6dfc030e01cbe96822dfef9dce12e9f1c4"
|
|
54
54
|
}
|