cspell-trie-lib 5.12.4 → 5.12.5
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/package.json +3 -3
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell-trie-lib",
|
|
3
|
-
"version": "5.12.
|
|
3
|
+
"version": "5.12.5",
|
|
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.
|
|
46
|
+
"@cspell/dict-en_us": "^2.1.3",
|
|
47
47
|
"@cspell/dict-es-es": "^2.0.2",
|
|
48
48
|
"@types/fs-extra": "^9.0.13",
|
|
49
49
|
"@types/node": "^16.11.6",
|
|
50
50
|
"jest": "^27.3.1",
|
|
51
51
|
"rimraf": "^3.0.2"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "84a21d1f7cbd17cc9633aafdff6dce19d6de35b5"
|
|
54
54
|
}
|