Comparing version 1.10.3 to 1.10.4
# Release Notes | ||
## 1.10.4 | ||
- Improved support for compound word suggestions. | ||
- Sped up suggestions on large compound words by a factor of 10x. | ||
Large compound words suggestions are still slow: ~4000ms to generate 8 suggestions for a 27 character word. | ||
This time can be reduced to about 1 second by changing the number of suggestions to 1. | ||
## 1.10.3 | ||
- Initial support for compound word suggestions. | ||
## 1.10.0 - 1.10.2 | ||
@@ -4,0 +13,0 @@ - Add support for compound word suggestion. |
export * from './Settings'; | ||
export { TextOffset, TextDocumentOffset } from './util/text'; | ||
export { validateText } from './validator'; | ||
export { mergeSettings, readSettings, readSettingsFiles, defaultFileName as defaultSettingsFilename, clearCachedFiles as clearCachedSettings, calcOverrideSettings } from './Settings'; | ||
export { SpellingDictionary, createSpellingDictionary, createSpellingDictionaryRx, getDictionary, SuggestionResult, SuggestionCollector } from './SpellingDictionary'; | ||
export { calcOverrideSettings, clearCachedFiles as clearCachedSettings, defaultFileName as defaultSettingsFilename, mergeSettings, readSettings, readSettingsFiles } from './Settings'; | ||
export { CompoundWordsMethod, createSpellingDictionary, createSpellingDictionaryRx, getDictionary, SpellingDictionary, SuggestionCollector, SuggestionResult } from './SpellingDictionary'; | ||
export { getDefaultSettings, getGlobalSettings } from './Settings'; | ||
@@ -7,0 +7,0 @@ export { combineTextAndLanguageSettings } from './Settings/TextDocumentSettings'; |
@@ -10,9 +10,10 @@ "use strict"; | ||
var Settings_1 = require("./Settings"); | ||
exports.calcOverrideSettings = Settings_1.calcOverrideSettings; | ||
exports.clearCachedSettings = Settings_1.clearCachedFiles; | ||
exports.defaultSettingsFilename = Settings_1.defaultFileName; | ||
exports.mergeSettings = Settings_1.mergeSettings; | ||
exports.readSettings = Settings_1.readSettings; | ||
exports.readSettingsFiles = Settings_1.readSettingsFiles; | ||
exports.defaultSettingsFilename = Settings_1.defaultFileName; | ||
exports.clearCachedSettings = Settings_1.clearCachedFiles; | ||
exports.calcOverrideSettings = Settings_1.calcOverrideSettings; | ||
var SpellingDictionary_1 = require("./SpellingDictionary"); | ||
exports.CompoundWordsMethod = SpellingDictionary_1.CompoundWordsMethod; | ||
exports.createSpellingDictionary = SpellingDictionary_1.createSpellingDictionary; | ||
@@ -19,0 +20,0 @@ exports.createSpellingDictionaryRx = SpellingDictionary_1.createSpellingDictionaryRx; |
@@ -19,3 +19,20 @@ "use strict"; | ||
}); | ||
it('Tests suggestions', function () { | ||
this.timeout(5000); | ||
const ext = '.txt'; | ||
const languageIds = cspell.getLanguagesForExt(ext); | ||
const settings = cspell.getDefaultSettings(); | ||
// cspell:ignore jansons | ||
const text = '{ "name": "Jansons"}'; | ||
const fileSettings = cspell.combineTextAndLanguageSettings(settings, text, languageIds); | ||
const finalSettings = cspell.finalizeSettings(fileSettings); | ||
const dict = cspell.getDictionary(finalSettings); | ||
// cspell:ignore installsallnecessary | ||
return dict.then(dict => { | ||
const results = dict.suggest('installsallnecessary', 10, cspell.CompoundWordsMethod.SEPARATE_WORDS); | ||
const sugs = results.map(a => a.word); | ||
chai_1.expect(sugs).to.contain('installs all necessary'); | ||
}); | ||
}); | ||
}); | ||
//# sourceMappingURL=index.test.js.map |
@@ -5,3 +5,3 @@ import * as Rx from 'rxjs/Rx'; | ||
import { ReplaceMap } from '../util/repMap'; | ||
export { SuggestionCollector, suggestionCollector, SuggestionResult, CompoundWordsMethod } from 'cspell-trie'; | ||
export { CompoundWordsMethod, JOIN_SEPARATOR, SuggestionCollector, suggestionCollector, SuggestionResult, WORD_SEPARATOR } from 'cspell-trie'; | ||
export declare type FilterSuggestionsPredicate = (word: SuggestionResult) => boolean; | ||
@@ -8,0 +8,0 @@ export interface SpellingDictionary { |
@@ -7,4 +7,6 @@ "use strict"; | ||
var cspell_trie_2 = require("cspell-trie"); | ||
exports.CompoundWordsMethod = cspell_trie_2.CompoundWordsMethod; | ||
exports.JOIN_SEPARATOR = cspell_trie_2.JOIN_SEPARATOR; | ||
exports.suggestionCollector = cspell_trie_2.suggestionCollector; | ||
exports.CompoundWordsMethod = cspell_trie_2.CompoundWordsMethod; | ||
exports.WORD_SEPARATOR = cspell_trie_2.WORD_SEPARATOR; | ||
const defaultSuggestions = 10; | ||
@@ -11,0 +13,0 @@ class SpellingDictionaryFromSet { |
@@ -41,2 +41,3 @@ "use strict"; | ||
it('checks for compound suggestions', () => { | ||
// Add "wordsA" twice, once as a compound dictionary and once as a normal dictionary. | ||
const trie = new SpellingDictionary_1.SpellingDictionaryFromTrie(Trie.Trie.create(wordsA), 'wordsA'); | ||
@@ -55,5 +56,21 @@ trie.options.useCompounds = true; | ||
chai_1.expect(sugs).to.be.not.empty; | ||
chai_1.expect(sugs).to.contain('applemango'); | ||
chai_1.expect(sugs).to.contain('apple+mango'); | ||
chai_1.expect(sugs).to.contain('apple mango'); | ||
}); | ||
it('checks for compound suggestions', () => { | ||
const trie = new SpellingDictionary_1.SpellingDictionaryFromTrie(Trie.Trie.create(wordsA), 'wordsA'); | ||
const dicts = [ | ||
trie, | ||
SpellingDictionary_1.createSpellingDictionary(wordsB, 'wordsB'), | ||
SpellingDictionary_1.createSpellingDictionary(wordsA, 'wordsA'), | ||
SpellingDictionary_1.createSpellingDictionary(wordsC, 'wordsC'), | ||
]; | ||
// cspell:ignore appletango applemango | ||
const dictCollection = SpellingDictionaryCollection_1.createCollection(dicts, 'test', ['Avocado']); | ||
const sugResult = dictCollection.suggest('appletango', 10, SpellingDictionary_1.CompoundWordsMethod.SEPARATE_WORDS); | ||
const sugs = sugResult.map(a => a.word); | ||
chai_1.expect(sugs).to.be.not.empty; | ||
chai_1.expect(sugs).to.not.contain('apple+mango'); | ||
chai_1.expect(sugs).to.contain('apple mango'); | ||
}); | ||
it('checks for suggestions with flagged words', () => { | ||
@@ -60,0 +77,0 @@ const dicts = [ |
@@ -0,1 +1,2 @@ | ||
export declare const uniqueFn: typeof uniqueFilterFnGenerator; | ||
export declare function uniqueFilterFnGenerator<T>(): (v: T) => boolean; | ||
@@ -2,0 +3,0 @@ export declare function uniqueFilterFnGenerator<T, U>(extractFn: (v: T) => U): (v: T) => boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// alias for uniqueFilterFnGenerator | ||
exports.uniqueFn = uniqueFilterFnGenerator; | ||
function uniqueFilterFnGenerator(extractFn) { | ||
@@ -4,0 +6,0 @@ const values = new Set(); |
{ | ||
"name": "cspell", | ||
"version": "1.10.3", | ||
"version": "1.10.4", | ||
"description": "A Spelling Checker for Code!", | ||
@@ -36,2 +36,3 @@ "main": "dist/index.js", | ||
"which": "which node && echo $PATH", | ||
"test-spec": "mocha --recursive \"dist/**/*.spec.js\"", | ||
"test": "mocha --recursive \"dist/**/*.test.js\"" | ||
@@ -63,7 +64,7 @@ }, | ||
"@types/chalk": "^0.4.31", | ||
"@types/commander": "^2.9.2", | ||
"@types/commander": "^2.11.0", | ||
"@types/comment-json": "^1.1.0", | ||
"@types/configstore": "^2.1.1", | ||
"@types/fs-extra": "^3.0.3", | ||
"@types/glob": "^5.0.32", | ||
"@types/glob": "^5.0.33", | ||
"@types/lorem-ipsum": "^1.0.2", | ||
@@ -76,2 +77,3 @@ "@types/minimatch": "^2.0.29", | ||
"coveralls": "^2.13.3", | ||
"cspell-dict-nl-nl": "^1.0.10", | ||
"cspell-tools": "^1.4.2", | ||
@@ -97,3 +99,3 @@ "lorem-ipsum": "^1.0.4", | ||
"cspell-lib": "^1.0.2", | ||
"cspell-trie": "^1.6.7", | ||
"cspell-trie": "^1.6.9", | ||
"fs-extra": "^3.0.0", | ||
@@ -116,3 +118,4 @@ "gensequence": "^2.1.1", | ||
"exclude": [ | ||
"src/**/*.test.ts" | ||
"src/**/*.test.ts", | ||
"src/**/*.spec.ts" | ||
], | ||
@@ -119,0 +122,0 @@ "extension": [ |
@@ -18,2 +18,21 @@ import {expect} from 'chai'; | ||
}); | ||
it('Tests suggestions', function() { | ||
this.timeout(5000); | ||
const ext = '.txt'; | ||
const languageIds = cspell.getLanguagesForExt(ext); | ||
const settings = cspell.getDefaultSettings(); | ||
// cspell:ignore jansons | ||
const text = '{ "name": "Jansons"}'; | ||
const fileSettings = cspell.combineTextAndLanguageSettings(settings, text, languageIds); | ||
const finalSettings = cspell.finalizeSettings(fileSettings); | ||
const dict = cspell.getDictionary(finalSettings); | ||
// cspell:ignore installsallnecessary | ||
return dict.then(dict => { | ||
const results = dict.suggest('installsallnecessary', 10, cspell.CompoundWordsMethod.SEPARATE_WORDS); | ||
const sugs = results.map(a => a.word); | ||
expect(sugs).to.contain('installs all necessary'); | ||
}); | ||
}); | ||
}); |
@@ -5,16 +5,17 @@ export * from './Settings'; | ||
export { | ||
calcOverrideSettings, | ||
clearCachedFiles as clearCachedSettings, | ||
defaultFileName as defaultSettingsFilename, | ||
mergeSettings, | ||
readSettings, | ||
readSettingsFiles, | ||
defaultFileName as defaultSettingsFilename, | ||
clearCachedFiles as clearCachedSettings, | ||
calcOverrideSettings | ||
} from './Settings'; | ||
export { | ||
SpellingDictionary, | ||
CompoundWordsMethod, | ||
createSpellingDictionary, | ||
createSpellingDictionaryRx, | ||
getDictionary, | ||
SpellingDictionary, | ||
SuggestionCollector, | ||
SuggestionResult, | ||
SuggestionCollector | ||
} from './SpellingDictionary'; | ||
@@ -21,0 +22,0 @@ export { getDefaultSettings, getGlobalSettings } from './Settings'; |
@@ -7,3 +7,10 @@ import { genSequence } from 'gensequence'; | ||
export {SuggestionCollector, suggestionCollector, SuggestionResult, CompoundWordsMethod } from 'cspell-trie'; | ||
export { | ||
CompoundWordsMethod, | ||
JOIN_SEPARATOR, | ||
SuggestionCollector, | ||
suggestionCollector, | ||
SuggestionResult, | ||
WORD_SEPARATOR, | ||
} from 'cspell-trie'; | ||
@@ -10,0 +17,0 @@ export type FilterSuggestionsPredicate = (word: SuggestionResult) => boolean; |
@@ -44,2 +44,3 @@ import { expect } from 'chai'; | ||
it('checks for compound suggestions', () => { | ||
// Add "wordsA" twice, once as a compound dictionary and once as a normal dictionary. | ||
const trie = new SpellingDictionaryFromTrie(Trie.Trie.create(wordsA), 'wordsA'); | ||
@@ -59,6 +60,24 @@ trie.options.useCompounds = true; | ||
expect(sugs).to.be.not.empty; | ||
expect(sugs).to.contain('applemango'); | ||
expect(sugs).to.contain('apple+mango'); | ||
expect(sugs).to.contain('apple mango'); | ||
}); | ||
it('checks for compound suggestions', () => { | ||
const trie = new SpellingDictionaryFromTrie(Trie.Trie.create(wordsA), 'wordsA'); | ||
const dicts = [ | ||
trie, | ||
createSpellingDictionary(wordsB, 'wordsB'), | ||
createSpellingDictionary(wordsA, 'wordsA'), | ||
createSpellingDictionary(wordsC, 'wordsC'), | ||
]; | ||
// cspell:ignore appletango applemango | ||
const dictCollection = createCollection(dicts, 'test', ['Avocado']); | ||
const sugResult = dictCollection.suggest('appletango', 10, CompoundWordsMethod.SEPARATE_WORDS); | ||
const sugs = sugResult.map(a => a.word); | ||
expect(sugs).to.be.not.empty; | ||
expect(sugs).to.not.contain('apple+mango'); | ||
expect(sugs).to.contain('apple mango'); | ||
}); | ||
it('checks for suggestions with flagged words', () => { | ||
@@ -65,0 +84,0 @@ const dicts = [ |
// alias for uniqueFilterFnGenerator | ||
export const uniqueFn = uniqueFilterFnGenerator; | ||
export function uniqueFilterFnGenerator<T>(): (v: T) => boolean; | ||
@@ -3,0 +6,0 @@ export function uniqueFilterFnGenerator<T, U>(extractFn: (v: T) => U): (v: T) => boolean; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
671210
246
7921
23
8
Updatedcspell-trie@^1.6.9