cspell-trie-lib 10.3.6 → 10.4.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/index.d.ts +69 -60
- package/dist/index.js +26 -17
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ interface PenaltyAdjustment {
|
|
|
63
63
|
* @param editCost - the cost of each edit (defaults to 100)
|
|
64
64
|
* @returns the edit distance.
|
|
65
65
|
*/
|
|
66
|
-
declare function editDistance(wordA: string, wordB: string, editCost?: number): number;
|
|
66
|
+
export declare function editDistance(wordA: string, wordB: string, editCost?: number): number;
|
|
67
67
|
/**
|
|
68
68
|
* Calculate the weighted edit distance between any two words.
|
|
69
69
|
* @param wordA
|
|
@@ -72,13 +72,13 @@ declare function editDistance(wordA: string, wordB: string, editCost?: number):
|
|
|
72
72
|
* @param editCost - the cost of each edit (defaults to 100)
|
|
73
73
|
* @returns the edit distance
|
|
74
74
|
*/
|
|
75
|
-
declare function editDistanceWeighted(wordA: string, wordB: string, weights: WeightMap, editCost?: number): number;
|
|
75
|
+
export declare function editDistanceWeighted(wordA: string, wordB: string, weights: WeightMap, editCost?: number): number;
|
|
76
76
|
/**
|
|
77
77
|
* Collect Map definitions into a single weighted map.
|
|
78
78
|
* @param defs - list of definitions
|
|
79
79
|
* @returns A Weighted Map to be used with distance calculations.
|
|
80
80
|
*/
|
|
81
|
-
declare function createWeightedMap(defs: SuggestionCostMapDef[]): WeightMap;
|
|
81
|
+
export declare function createWeightedMap(defs: SuggestionCostMapDef[]): WeightMap;
|
|
82
82
|
//#endregion
|
|
83
83
|
//#region src/lib/types.d.ts
|
|
84
84
|
/**
|
|
@@ -194,7 +194,7 @@ type TrieOptionsRO = Readonly<TrieOptions>;
|
|
|
194
194
|
type PartialTrieOptions = PartialTrieInfo;
|
|
195
195
|
//#endregion
|
|
196
196
|
//#region src/lib/TrieNode/TrieNode.d.ts
|
|
197
|
-
declare const FLAG_WORD = 1;
|
|
197
|
+
export declare const FLAG_WORD = 1;
|
|
198
198
|
type ChildMap = Record<string, TrieNode>;
|
|
199
199
|
interface TrieNode {
|
|
200
200
|
f?: number | undefined;
|
|
@@ -205,8 +205,8 @@ interface TrieRoot extends TrieInfo, TrieCharacteristics {
|
|
|
205
205
|
}
|
|
206
206
|
//#endregion
|
|
207
207
|
//#region src/lib/walker/walkerTypes.d.ts
|
|
208
|
-
declare const JOIN_SEPARATOR = "+";
|
|
209
|
-
declare const WORD_SEPARATOR = " ";
|
|
208
|
+
export declare const JOIN_SEPARATOR = "+";
|
|
209
|
+
export declare const WORD_SEPARATOR = " ";
|
|
210
210
|
interface YieldResult {
|
|
211
211
|
text: string;
|
|
212
212
|
node: TrieNode;
|
|
@@ -227,13 +227,13 @@ declare const CompoundWordsMethodEnum: {
|
|
|
227
227
|
readonly JOIN_WORDS: 2;
|
|
228
228
|
};
|
|
229
229
|
type CompoundWordsMethodEnum = typeof CompoundWordsMethodEnum;
|
|
230
|
-
type CompoundWordsMethod = CompoundWordsMethodEnum[keyof CompoundWordsMethodEnum];
|
|
230
|
+
export type CompoundWordsMethod = CompoundWordsMethodEnum[keyof CompoundWordsMethodEnum];
|
|
231
231
|
interface CompoundWordsMethodByName extends CompoundWordsMethodEnum {
|
|
232
232
|
"0": "NONE";
|
|
233
233
|
"1": "SEPARATE_WORDS";
|
|
234
234
|
"2": "JOIN_WORDS";
|
|
235
235
|
}
|
|
236
|
-
declare const CompoundWordsMethod: CompoundWordsMethodByName;
|
|
236
|
+
export declare const CompoundWordsMethod: CompoundWordsMethodByName;
|
|
237
237
|
type WalkerIterator = Generator<YieldResult, void, boolean | undefined>;
|
|
238
238
|
//#endregion
|
|
239
239
|
//#region src/lib/ITrieNode/walker/walkerTypes.d.ts
|
|
@@ -256,13 +256,13 @@ type WalkerIterator$1 = Generator<YieldResult$1, void, FalseToNotGoDeeper | unde
|
|
|
256
256
|
* This can be used to limit the walker's depth.
|
|
257
257
|
*/
|
|
258
258
|
type HintedWalkerIterator = Generator<YieldResult, void, Hinting | undefined>;
|
|
259
|
-
declare function hintedWalker(root: TrieRoot, ignoreCase: boolean, hint: string, compoundingMethod: CompoundWordsMethod | undefined, emitWordSeparator?: string): HintedWalkerIterator;
|
|
259
|
+
export declare function hintedWalker(root: TrieRoot, ignoreCase: boolean, hint: string, compoundingMethod: CompoundWordsMethod | undefined, emitWordSeparator?: string): HintedWalkerIterator;
|
|
260
260
|
interface Hinting {
|
|
261
261
|
goDeeper: boolean;
|
|
262
262
|
}
|
|
263
263
|
//#endregion
|
|
264
264
|
//#region src/lib/walker/walker.d.ts
|
|
265
|
-
declare function walker(root: TrieNode, compoundingMethod?: CompoundWordsMethod): WalkerIterator;
|
|
265
|
+
export declare function walker(root: TrieNode, compoundingMethod?: CompoundWordsMethod): WalkerIterator;
|
|
266
266
|
//#endregion
|
|
267
267
|
//#region src/lib/suggestions/genSuggestionsOptions.d.ts
|
|
268
268
|
interface GenSuggestionOptionsStrict {
|
|
@@ -422,7 +422,7 @@ interface SuggestionCollectorOptions extends Omit<GenSuggestionOptionsStrictRO,
|
|
|
422
422
|
weightMap?: WeightMap | undefined;
|
|
423
423
|
}
|
|
424
424
|
type SuggestionCollectorOptionsRO = Readonly<SuggestionCollectorOptions>;
|
|
425
|
-
declare function suggestionCollector(wordToMatch: string, options: SuggestionCollectorOptionsRO): SuggestionCollector;
|
|
425
|
+
export declare function suggestionCollector(wordToMatch: string, options: SuggestionCollectorOptionsRO): SuggestionCollector;
|
|
426
426
|
/**
|
|
427
427
|
* Impersonating a Collector, allows searching for multiple variants on the same word.
|
|
428
428
|
* The collection is still in the original collector.
|
|
@@ -430,7 +430,7 @@ declare function suggestionCollector(wordToMatch: string, options: SuggestionCol
|
|
|
430
430
|
* @param word - word to present instead of `collector.word`.
|
|
431
431
|
* @returns a SuggestionCollector
|
|
432
432
|
*/
|
|
433
|
-
declare function impersonateCollector(collector: SuggestionCollector, word: string): SuggestionCollector;
|
|
433
|
+
export declare function impersonateCollector(collector: SuggestionCollector, word: string): SuggestionCollector;
|
|
434
434
|
//#endregion
|
|
435
435
|
//#region src/lib/TrieData.d.ts
|
|
436
436
|
interface TrieDataFundamentals {
|
|
@@ -589,21 +589,21 @@ interface FindWordOptions {
|
|
|
589
589
|
type FindWordOptionsRO = Readonly<FindWordOptions>;
|
|
590
590
|
//#endregion
|
|
591
591
|
//#region src/lib/buildITrie.d.ts
|
|
592
|
-
declare function buildITrieFromWords(words: Iterable<string>, info?: PartialTrieInfo, buildOptions?: BuildOptions): ITrie;
|
|
592
|
+
export declare function buildITrieFromWords(words: Iterable<string>, info?: PartialTrieInfo, buildOptions?: BuildOptions): ITrie;
|
|
593
593
|
//#endregion
|
|
594
594
|
//#region src/lib/consolidate.d.ts
|
|
595
595
|
/**
|
|
596
596
|
* Consolidate to DAWG
|
|
597
597
|
* @param root the root of the Trie tree
|
|
598
598
|
*/
|
|
599
|
-
declare function consolidate(root: TrieRoot): TrieRoot;
|
|
599
|
+
export declare function consolidate(root: TrieRoot): TrieRoot;
|
|
600
600
|
//#endregion
|
|
601
601
|
//#region src/lib/constants.d.ts
|
|
602
|
-
declare const COMPOUND_FIX = "+";
|
|
603
|
-
declare const OPTIONAL_COMPOUND_FIX = "*";
|
|
604
|
-
declare const CASE_INSENSITIVE_PREFIX = "~";
|
|
605
|
-
declare const FORBID_PREFIX = "!";
|
|
606
|
-
declare const defaultTrieInfo: TrieInfo;
|
|
602
|
+
export declare const COMPOUND_FIX = "+";
|
|
603
|
+
export declare const OPTIONAL_COMPOUND_FIX = "*";
|
|
604
|
+
export declare const CASE_INSENSITIVE_PREFIX = "~";
|
|
605
|
+
export declare const FORBID_PREFIX = "!";
|
|
606
|
+
export declare const defaultTrieInfo: TrieInfo;
|
|
607
607
|
//#endregion
|
|
608
608
|
//#region ../cspell-pipe/dist/operators/types.d.ts
|
|
609
609
|
type OperatorSync<T, U = T> = (i: Iterable<T>) => Iterable<U>;
|
|
@@ -625,7 +625,7 @@ interface FindFullResult extends FindResult {
|
|
|
625
625
|
}
|
|
626
626
|
//#endregion
|
|
627
627
|
//#region src/lib/trie.d.ts
|
|
628
|
-
declare class Trie {
|
|
628
|
+
export declare class Trie {
|
|
629
629
|
#private;
|
|
630
630
|
private _options;
|
|
631
631
|
private _findOptionsDefaults;
|
|
@@ -745,6 +745,11 @@ interface ParseDictionaryOptions extends BuildOptions {
|
|
|
745
745
|
* @default false
|
|
746
746
|
*/
|
|
747
747
|
stripCaseAndAccentsOnForbidden: boolean;
|
|
748
|
+
/**
|
|
749
|
+
* The locale whose case rules are used to create the case insensitive forms.
|
|
750
|
+
* Default rules are used if not given.
|
|
751
|
+
*/
|
|
752
|
+
locale?: string | undefined;
|
|
748
753
|
/**
|
|
749
754
|
* Tell the parser to split into words along spaces.
|
|
750
755
|
* @default false
|
|
@@ -812,12 +817,12 @@ declare function createDictionaryLineParserMapper(options?: Partial<ParseDiction
|
|
|
812
817
|
* @param _options - defines prefixes used when parsing lines.
|
|
813
818
|
* @returns words that have been normalized.
|
|
814
819
|
*/
|
|
815
|
-
declare function parseDictionaryLines(lines: Iterable<string> | string, options?: Partial<ParseDictionaryOptions>): Iterable<string>;
|
|
816
|
-
declare function parseDictionaryLegacy(text: string | string[], options?: Partial<ParseDictionaryOptions>): Trie;
|
|
817
|
-
declare function parseDictionary(text: string | Iterable<string>, options?: Partial<ParseDictionaryOptions>): ITrie;
|
|
820
|
+
export declare function parseDictionaryLines(lines: Iterable<string> | string, options?: Partial<ParseDictionaryOptions>): Iterable<string>;
|
|
821
|
+
export declare function parseDictionaryLegacy(text: string | string[], options?: Partial<ParseDictionaryOptions>): Trie;
|
|
822
|
+
export declare function parseDictionary(text: string | Iterable<string>, options?: Partial<ParseDictionaryOptions>): ITrie;
|
|
818
823
|
//#endregion
|
|
819
824
|
//#region src/lib/decodeTrie.d.ts
|
|
820
|
-
declare function decodeTrie(raw: string | ArrayBufferView<ArrayBuffer> | Uint8Array<ArrayBuffer>): ITrie;
|
|
825
|
+
export declare function decodeTrie(raw: string | ArrayBufferView<ArrayBuffer> | Uint8Array<ArrayBuffer>): ITrie;
|
|
821
826
|
interface FileResource {
|
|
822
827
|
/**
|
|
823
828
|
* The URL of the File
|
|
@@ -828,11 +833,11 @@ interface FileResource {
|
|
|
828
833
|
*/
|
|
829
834
|
readonly content: string | Uint8Array<ArrayBuffer>;
|
|
830
835
|
}
|
|
831
|
-
declare function decodeFile(file: FileResource, options?: Partial<ParseDictionaryOptions>): Promise<ITrie>;
|
|
832
|
-
declare function convertToBTrie(file: FileResource, options?: Partial<ParseDictionaryOptions>): Promise<FileResource>;
|
|
836
|
+
export declare function decodeFile(file: FileResource, options?: Partial<ParseDictionaryOptions>): Promise<ITrie>;
|
|
837
|
+
export declare function convertToBTrie(file: FileResource, options?: Partial<ParseDictionaryOptions>): Promise<FileResource>;
|
|
833
838
|
//#endregion
|
|
834
839
|
//#region src/lib/GTrie/GTrie.d.ts
|
|
835
|
-
declare class GTrieNode<K, V> {
|
|
840
|
+
export declare class GTrieNode<K, V> {
|
|
836
841
|
children: Map<K, GTrieNode<K, V>> | undefined;
|
|
837
842
|
value: V | undefined;
|
|
838
843
|
constructor(value?: V, children?: Map<K, GTrieNode<K, V>>);
|
|
@@ -846,7 +851,7 @@ declare class GTrieNode<K, V> {
|
|
|
846
851
|
* K - Key type
|
|
847
852
|
* V - Value type
|
|
848
853
|
*/
|
|
849
|
-
declare class GTrie<K, V> {
|
|
854
|
+
export declare class GTrie<K, V> {
|
|
850
855
|
root: GTrieNode<K, V>;
|
|
851
856
|
constructor();
|
|
852
857
|
/**
|
|
@@ -883,18 +888,18 @@ interface ExportOptions {
|
|
|
883
888
|
* Even though it is possible to preserve the trie, dealing with very large tries can consume a lot of memory.
|
|
884
889
|
* Considering this is the last step before exporting, it was decided to let this be destructive.
|
|
885
890
|
*/
|
|
886
|
-
declare function serializeTrie(root: TrieRoot, options?: ExportOptions | number): Iterable<string>;
|
|
887
|
-
declare function importTrie(input: Iterable<string> | IterableIterator<string> | string[] | string): TrieRoot;
|
|
891
|
+
export declare function serializeTrie(root: TrieRoot, options?: ExportOptions | number): Iterable<string>;
|
|
892
|
+
export declare function importTrie(input: Iterable<string> | IterableIterator<string> | string[] | string): TrieRoot;
|
|
888
893
|
//#endregion
|
|
889
894
|
//#region src/lib/models/DictionaryInformation.d.ts
|
|
890
895
|
type DictionaryInformation = Exclude<DictionaryDefinitionAugmented["dictionaryInformation"], undefined>;
|
|
891
896
|
//#endregion
|
|
892
897
|
//#region src/lib/mappers/mapDictionaryInfoToWeightMap.d.ts
|
|
893
|
-
declare function mapDictionaryInformationToWeightMap(dictInfo: DictionaryInformation): WeightMap;
|
|
898
|
+
export declare function mapDictionaryInformationToWeightMap(dictInfo: DictionaryInformation): WeightMap;
|
|
894
899
|
//#endregion
|
|
895
900
|
//#region src/lib/TrieBlob/trieDataEncoder.d.ts
|
|
896
|
-
declare function encodeITrieToBTrie(trie: ITrie, buildOptions?: BuildOptions): Uint8Array<ArrayBuffer>;
|
|
897
|
-
declare function encodeTrieDataToBTrie(data: TrieData, buildOptions?: BuildOptions): Uint8Array<ArrayBuffer>;
|
|
901
|
+
export declare function encodeITrieToBTrie(trie: ITrie, buildOptions?: BuildOptions): Uint8Array<ArrayBuffer>;
|
|
902
|
+
export declare function encodeTrieDataToBTrie(data: TrieData, buildOptions?: BuildOptions): Uint8Array<ArrayBuffer>;
|
|
898
903
|
//#endregion
|
|
899
904
|
//#region src/lib/TrieBuilder.d.ts
|
|
900
905
|
/**
|
|
@@ -903,14 +908,14 @@ declare function encodeTrieDataToBTrie(data: TrieData, buildOptions?: BuildOptio
|
|
|
903
908
|
* @param words Iterable set of words -- no processing is done on the words, they are inserted as is.
|
|
904
909
|
* @param trieOptions options for the Trie
|
|
905
910
|
*/
|
|
906
|
-
declare function buildTrie(words: Iterable<string>, trieOptions?: PartialTrieOptions): Trie;
|
|
911
|
+
export declare function buildTrie(words: Iterable<string>, trieOptions?: PartialTrieOptions): Trie;
|
|
907
912
|
/**
|
|
908
913
|
* Builds a Trie from a Iterable<string>. NO attempt a reducing the size of the Trie is done.
|
|
909
914
|
* @param words Iterable set of words -- no processing is done on the words, they are inserted as is.
|
|
910
915
|
* @param trieOptions options for the Trie
|
|
911
916
|
*/
|
|
912
|
-
declare function buildTrieFast(words: Iterable<string>, trieOptions?: PartialTrieOptions): Trie;
|
|
913
|
-
declare class TrieBuilder {
|
|
917
|
+
export declare function buildTrieFast(words: Iterable<string>, trieOptions?: PartialTrieOptions): Trie;
|
|
918
|
+
export declare class TrieBuilder {
|
|
914
919
|
#private;
|
|
915
920
|
private count;
|
|
916
921
|
private readonly signatures;
|
|
@@ -936,32 +941,32 @@ declare class TrieBuilder {
|
|
|
936
941
|
}
|
|
937
942
|
//#endregion
|
|
938
943
|
//#region src/lib/TrieNode/trie-util.d.ts
|
|
939
|
-
declare function insert(word: string, root?: TrieNode): TrieNode;
|
|
940
|
-
declare function isWordTerminationNode(node: TrieNode): boolean;
|
|
944
|
+
export declare function insert(word: string, root?: TrieNode): TrieNode;
|
|
945
|
+
export declare function isWordTerminationNode(node: TrieNode): boolean;
|
|
941
946
|
/**
|
|
942
947
|
* Sorts the nodes in a trie in place.
|
|
943
948
|
*/
|
|
944
|
-
declare function orderTrie(node: TrieNode): void;
|
|
949
|
+
export declare function orderTrie(node: TrieNode): void;
|
|
945
950
|
/**
|
|
946
951
|
* Generator an iterator that will walk the Trie parent then children in a depth first fashion that preserves sorted order.
|
|
947
952
|
*/
|
|
948
|
-
declare function walk(node: TrieNode): Iterable<YieldResult>;
|
|
949
|
-
declare const iterateTrie: typeof walk;
|
|
953
|
+
export declare function walk(node: TrieNode): Iterable<YieldResult>;
|
|
954
|
+
export declare const iterateTrie: typeof walk;
|
|
950
955
|
/**
|
|
951
956
|
* Generate a Iterator that can walk a Trie and yield the words.
|
|
952
957
|
*/
|
|
953
|
-
declare function iteratorTrieWords(node: TrieNode): Iterable<string>;
|
|
954
|
-
declare function createTrieRoot(options?: PartialTrieInfoRO): TrieRoot;
|
|
955
|
-
declare function createTrieRootFromList(words: Iterable<string>, options?: PartialTrieInfo): TrieRoot;
|
|
956
|
-
declare function has(node: TrieNode, word: string): boolean;
|
|
957
|
-
declare function findNode(node: TrieNode, word: string): TrieNode | undefined;
|
|
958
|
-
declare function countNodes(root: TrieNode): number;
|
|
959
|
-
declare function countWords(root: TrieNode): number;
|
|
960
|
-
declare function isCircular(root: TrieNode): boolean;
|
|
961
|
-
declare function trieNodeToRoot(node: TrieNode, options: PartialTrieInfo): TrieRoot;
|
|
958
|
+
export declare function iteratorTrieWords(node: TrieNode): Iterable<string>;
|
|
959
|
+
export declare function createTrieRoot(options?: PartialTrieInfoRO): TrieRoot;
|
|
960
|
+
export declare function createTrieRootFromList(words: Iterable<string>, options?: PartialTrieInfo): TrieRoot;
|
|
961
|
+
export declare function has(node: TrieNode, word: string): boolean;
|
|
962
|
+
export declare function findNode(node: TrieNode, word: string): TrieNode | undefined;
|
|
963
|
+
export declare function countNodes(root: TrieNode): number;
|
|
964
|
+
export declare function countWords(root: TrieNode): number;
|
|
965
|
+
export declare function isCircular(root: TrieNode): boolean;
|
|
966
|
+
export declare function trieNodeToRoot(node: TrieNode, options: PartialTrieInfo): TrieRoot;
|
|
962
967
|
//#endregion
|
|
963
968
|
//#region src/lib/utils/isDefined.d.ts
|
|
964
|
-
declare function isDefined<T>(t: T | undefined): t is T;
|
|
969
|
+
export declare function isDefined<T>(t: T | undefined): t is T;
|
|
965
970
|
//#endregion
|
|
966
971
|
//#region src/lib/utils/mergeDefaults.d.ts
|
|
967
972
|
/**
|
|
@@ -971,12 +976,12 @@ declare function isDefined<T>(t: T | undefined): t is T;
|
|
|
971
976
|
* @param value
|
|
972
977
|
* @param defaultValue
|
|
973
978
|
*/
|
|
974
|
-
declare function mergeDefaults<T extends object>(value: Readonly<PartialWithUndefined<T>> | undefined, defaultValue: T): T;
|
|
979
|
+
export declare function mergeDefaults<T extends object>(value: Readonly<PartialWithUndefined<T>> | undefined, defaultValue: T): T;
|
|
975
980
|
//#endregion
|
|
976
981
|
//#region src/lib/utils/mergeOptionalWithDefaults.d.ts
|
|
977
982
|
type ROPartialTrieOptions = Readonly<PartialTrieInfo>;
|
|
978
|
-
declare function mergeOptionalWithDefaults(options: ROPartialTrieOptions): TrieInfo;
|
|
979
|
-
declare function mergeOptionalWithDefaults(options: ROPartialTrieOptions, ...moreOptions: ROPartialTrieOptions[]): TrieInfo;
|
|
983
|
+
export declare function mergeOptionalWithDefaults(options: ROPartialTrieOptions): TrieInfo;
|
|
984
|
+
export declare function mergeOptionalWithDefaults(options: ROPartialTrieOptions, ...moreOptions: ROPartialTrieOptions[]): TrieInfo;
|
|
980
985
|
//#endregion
|
|
981
986
|
//#region src/lib/utils/normalizeWord.d.ts
|
|
982
987
|
/**
|
|
@@ -984,20 +989,24 @@ declare function mergeOptionalWithDefaults(options: ROPartialTrieOptions, ...mor
|
|
|
984
989
|
* @param text - text to normalize
|
|
985
990
|
* @returns returns a word normalized to `NFC`
|
|
986
991
|
*/
|
|
987
|
-
declare
|
|
992
|
+
export declare function normalizeWord(text: string): string;
|
|
988
993
|
/**
|
|
989
994
|
* converts text to lower case and removes any accents.
|
|
990
995
|
* @param text - text to convert
|
|
991
996
|
* @returns lowercase word without accents
|
|
992
|
-
* @deprecated true
|
|
993
997
|
*/
|
|
994
|
-
declare
|
|
998
|
+
export declare function normalizeWordToLowercaseAndRemoveAccents(text: string): string;
|
|
999
|
+
/**
|
|
1000
|
+
* @deprecated Use {@link normalizeWordToLowercaseAndRemoveAccents}.
|
|
1001
|
+
*/
|
|
1002
|
+
export declare const normalizeWordToLowercase: (text: string) => string;
|
|
995
1003
|
/**
|
|
996
1004
|
* generate case insensitive forms of a word
|
|
997
1005
|
* @param text - text to convert
|
|
1006
|
+
* @param locale - the locale whose case rules are used to lower-case the text. Default rules are used if not given.
|
|
998
1007
|
* @returns the forms of the word.
|
|
999
1008
|
*/
|
|
1000
|
-
declare
|
|
1009
|
+
export declare function normalizeWordForCaseInsensitive(text: string, locale?: string): string[];
|
|
1001
1010
|
//#endregion
|
|
1002
1011
|
//#region src/lib/utils/text.d.ts
|
|
1003
1012
|
/**
|
|
@@ -1012,7 +1021,7 @@ declare const normalizeWordForCaseInsensitive: (text: string) => string[];
|
|
|
1012
1021
|
* @param line - set of characters
|
|
1013
1022
|
* @param rangeChar - the character to indicate ranges, set to empty to not have ranges.
|
|
1014
1023
|
*/
|
|
1015
|
-
declare function expandCharacterSet(line: string, rangeChar?: string): Set<string>;
|
|
1024
|
+
export declare function expandCharacterSet(line: string, rangeChar?: string): Set<string>;
|
|
1016
1025
|
//#endregion
|
|
1017
|
-
export {
|
|
1026
|
+
export { type ChildMap, type ExportOptions, type FindFullResult, type FindWordOptions, type HintedWalkerIterator, type Hinting, type ITrie, type MaxCost, type PartialTrieOptions, type SuggestionCollector, type SuggestionCostMapDef, type SuggestionResult, type TrieNode, type TrieOptions, type TrieOptionsRO, type TrieRoot, type WalkerIterator, type WeightMap, type YieldResult, createDictionaryLineParserMapper as createDictionaryLineParser, defaultTrieInfo as defaultTrieOptions };
|
|
1018
1027
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -210,7 +210,7 @@ Object.freeze(notFound);
|
|
|
210
210
|
/**
|
|
211
211
|
*
|
|
212
212
|
* @param root Trie root node. root.c contains the compound root and forbidden root.
|
|
213
|
-
* @param word A pre normalized word use `normalizeWord` or `
|
|
213
|
+
* @param word A pre normalized word use `normalizeWord` or `normalizeWordToLowercaseAndRemoveAccents`
|
|
214
214
|
* @param options
|
|
215
215
|
*/
|
|
216
216
|
function findWordNode$1(root, word, options) {
|
|
@@ -219,7 +219,7 @@ function findWordNode$1(root, word, options) {
|
|
|
219
219
|
/**
|
|
220
220
|
*
|
|
221
221
|
* @param root Trie root node. root.c contains the compound root and forbidden root.
|
|
222
|
-
* @param word A pre normalized word use `normalizeWord` or `
|
|
222
|
+
* @param word A pre normalized word use `normalizeWord` or `normalizeWordToLowercaseAndRemoveAccents`
|
|
223
223
|
* @param options
|
|
224
224
|
*/
|
|
225
225
|
function findWord$1(root, word, options) {
|
|
@@ -244,7 +244,7 @@ function findWord$1(root, word, options) {
|
|
|
244
244
|
/**
|
|
245
245
|
*
|
|
246
246
|
* @param root Trie root node. root.c contains the compound root and forbidden root.
|
|
247
|
-
* @param word A pre normalized word use `normalizeWord` or `
|
|
247
|
+
* @param word A pre normalized word use `normalizeWord` or `normalizeWordToLowercaseAndRemoveAccents`
|
|
248
248
|
* @param options
|
|
249
249
|
*/
|
|
250
250
|
function _findWordNode$1(root, word, options) {
|
|
@@ -5807,7 +5807,7 @@ const knownCompoundModes = new Map([
|
|
|
5807
5807
|
/**
|
|
5808
5808
|
*
|
|
5809
5809
|
* @param root Trie root node. root.c contains the compound root and forbidden root.
|
|
5810
|
-
* @param word A pre normalized word use `normalizeWord` or `
|
|
5810
|
+
* @param word A pre normalized word use `normalizeWord` or `normalizeWordToLowercaseAndRemoveAccents`
|
|
5811
5811
|
* @param options
|
|
5812
5812
|
*/
|
|
5813
5813
|
function findWord(root, word, options) {
|
|
@@ -5816,7 +5816,7 @@ function findWord(root, word, options) {
|
|
|
5816
5816
|
/**
|
|
5817
5817
|
*
|
|
5818
5818
|
* @param root Trie root node. root.c contains the compound root and forbidden root.
|
|
5819
|
-
* @param word A pre normalized word use `normalizeWord` or `
|
|
5819
|
+
* @param word A pre normalized word use `normalizeWord` or `normalizeWordToLowercaseAndRemoveAccents`
|
|
5820
5820
|
* @param options
|
|
5821
5821
|
*/
|
|
5822
5822
|
function findWordNode(root, word, options) {
|
|
@@ -5825,7 +5825,7 @@ function findWordNode(root, word, options) {
|
|
|
5825
5825
|
/**
|
|
5826
5826
|
*
|
|
5827
5827
|
* @param root Trie root node. root.c contains the compound root and forbidden root.
|
|
5828
|
-
* @param word A pre normalized word use `normalizeWord` or `
|
|
5828
|
+
* @param word A pre normalized word use `normalizeWord` or `normalizeWordToLowercaseAndRemoveAccents`
|
|
5829
5829
|
* @param options
|
|
5830
5830
|
*/
|
|
5831
5831
|
function _findWord(root, word, options) {
|
|
@@ -5835,7 +5835,7 @@ function _findWord(root, word, options) {
|
|
|
5835
5835
|
/**
|
|
5836
5836
|
*
|
|
5837
5837
|
* @param root Trie root node. root.c contains the compound root and forbidden root.
|
|
5838
|
-
* @param word A pre normalized word use `normalizeWord` or `
|
|
5838
|
+
* @param word A pre normalized word use `normalizeWord` or `normalizeWordToLowercaseAndRemoveAccents`
|
|
5839
5839
|
* @param options
|
|
5840
5840
|
*/
|
|
5841
5841
|
function _findWordNode(root, word, options) {
|
|
@@ -8181,23 +8181,31 @@ function assertFrozen(n) {
|
|
|
8181
8181
|
* @param text - text to normalize
|
|
8182
8182
|
* @returns returns a word normalized to `NFC`
|
|
8183
8183
|
*/
|
|
8184
|
-
|
|
8184
|
+
function normalizeWord(text) {
|
|
8185
|
+
return text.normalize();
|
|
8186
|
+
}
|
|
8185
8187
|
/**
|
|
8186
8188
|
* converts text to lower case and removes any accents.
|
|
8187
8189
|
* @param text - text to convert
|
|
8188
8190
|
* @returns lowercase word without accents
|
|
8189
|
-
* @deprecated true
|
|
8190
8191
|
*/
|
|
8191
|
-
|
|
8192
|
+
function normalizeWordToLowercaseAndRemoveAccents(text) {
|
|
8193
|
+
return text.toLowerCase().normalize("NFD").replaceAll(/\p{M}/gu, "");
|
|
8194
|
+
}
|
|
8195
|
+
/**
|
|
8196
|
+
* @deprecated Use {@link normalizeWordToLowercaseAndRemoveAccents}.
|
|
8197
|
+
*/
|
|
8198
|
+
const normalizeWordToLowercase = normalizeWordToLowercaseAndRemoveAccents;
|
|
8192
8199
|
/**
|
|
8193
8200
|
* generate case insensitive forms of a word
|
|
8194
8201
|
* @param text - text to convert
|
|
8202
|
+
* @param locale - the locale whose case rules are used to lower-case the text. Default rules are used if not given.
|
|
8195
8203
|
* @returns the forms of the word.
|
|
8196
8204
|
*/
|
|
8197
|
-
|
|
8198
|
-
const t = text.toLowerCase();
|
|
8205
|
+
function normalizeWordForCaseInsensitive(text, locale) {
|
|
8206
|
+
const t = locale ? text.toLocaleLowerCase(locale) : text.toLowerCase();
|
|
8199
8207
|
return [t, t.normalize("NFD").replaceAll(/\p{M}/gu, "")];
|
|
8200
|
-
}
|
|
8208
|
+
}
|
|
8201
8209
|
//#endregion
|
|
8202
8210
|
//#region src/lib/SimpleDictionaryParser.ts
|
|
8203
8211
|
const BATCH_SIZE = 0;
|
|
@@ -8217,7 +8225,8 @@ const _defaultOptions = {
|
|
|
8217
8225
|
keepOptionalCompoundCharacter: false,
|
|
8218
8226
|
suggestionPrefix: ":",
|
|
8219
8227
|
disableSuggestionHandling: false,
|
|
8220
|
-
makeWordsForbidden: false
|
|
8228
|
+
makeWordsForbidden: false,
|
|
8229
|
+
locale: void 0
|
|
8221
8230
|
};
|
|
8222
8231
|
Object.freeze(_defaultOptions);
|
|
8223
8232
|
const cSpellToolDirective = "cspell-dictionary:";
|
|
@@ -8229,7 +8238,7 @@ const cSpellToolDirective = "cspell-dictionary:";
|
|
|
8229
8238
|
*/
|
|
8230
8239
|
function createDictionaryLineParserMapper(options) {
|
|
8231
8240
|
const _options = options || _defaultOptions;
|
|
8232
|
-
const { commentCharacter = _defaultOptions.commentCharacter, optionalCompoundCharacter: optionalCompound = _defaultOptions.optionalCompoundCharacter, compoundCharacter: compound = _defaultOptions.compoundCharacter, caseInsensitivePrefix: ignoreCase = _defaultOptions.caseInsensitivePrefix, forbiddenPrefix: forbidden = _defaultOptions.forbiddenPrefix, keepExactPrefix: keepCase = _defaultOptions.keepExactPrefix, splitSeparator = _defaultOptions.splitSeparator, splitKeepBoth = _defaultOptions.splitKeepBoth, stripCaseAndAccentsKeepDuplicate = _defaultOptions.stripCaseAndAccentsKeepDuplicate, stripCaseAndAccentsOnForbidden = _defaultOptions.stripCaseAndAccentsOnForbidden, keepOptionalCompoundCharacter = _defaultOptions.keepOptionalCompoundCharacter, makeWordsForbidden = _defaultOptions.makeWordsForbidden } = _options;
|
|
8241
|
+
const { commentCharacter = _defaultOptions.commentCharacter, optionalCompoundCharacter: optionalCompound = _defaultOptions.optionalCompoundCharacter, compoundCharacter: compound = _defaultOptions.compoundCharacter, caseInsensitivePrefix: ignoreCase = _defaultOptions.caseInsensitivePrefix, forbiddenPrefix: forbidden = _defaultOptions.forbiddenPrefix, keepExactPrefix: keepCase = _defaultOptions.keepExactPrefix, splitSeparator = _defaultOptions.splitSeparator, splitKeepBoth = _defaultOptions.splitKeepBoth, stripCaseAndAccentsKeepDuplicate = _defaultOptions.stripCaseAndAccentsKeepDuplicate, stripCaseAndAccentsOnForbidden = _defaultOptions.stripCaseAndAccentsOnForbidden, keepOptionalCompoundCharacter = _defaultOptions.keepOptionalCompoundCharacter, makeWordsForbidden = _defaultOptions.makeWordsForbidden, locale = _defaultOptions.locale } = _options;
|
|
8233
8242
|
let { stripCaseAndAccents = !makeWordsForbidden && _defaultOptions.stripCaseAndAccents, split = _defaultOptions.split, suggestionPrefix = _defaultOptions.suggestionPrefix } = _options;
|
|
8234
8243
|
const disableSuggestionHandling = _options.disableSuggestionHandling || [
|
|
8235
8244
|
"",
|
|
@@ -8319,7 +8328,7 @@ function createDictionaryLineParserMapper(options) {
|
|
|
8319
8328
|
const nWord = _normalize(word);
|
|
8320
8329
|
const forms = /* @__PURE__ */ new Set();
|
|
8321
8330
|
forms.add(nWord);
|
|
8322
|
-
if (stripCaseAndAccents && !(word[0] in doNotNormalizePrefix)) for (const n of normalizeWordForCaseInsensitive(nWord)) (stripCaseAndAccentsKeepDuplicate || n !== nWord) && forms.add(ignoreCase + n);
|
|
8331
|
+
if (stripCaseAndAccents && !(word[0] in doNotNormalizePrefix)) for (const n of normalizeWordForCaseInsensitive(nWord, locale)) (stripCaseAndAccentsKeepDuplicate || n !== nWord) && forms.add(ignoreCase + n);
|
|
8323
8332
|
yield* forms;
|
|
8324
8333
|
}
|
|
8325
8334
|
function* splitWords(lines) {
|
|
@@ -11243,6 +11252,6 @@ function mapDictionaryInformationToWeightMap(dictInfo) {
|
|
|
11243
11252
|
return map;
|
|
11244
11253
|
}
|
|
11245
11254
|
//#endregion
|
|
11246
|
-
export { CASE_INSENSITIVE_PREFIX, COMPOUND_FIX, CompoundWordsMethod, FLAG_WORD, FORBID_PREFIX, GTrie, GTrieNode, JOIN_SEPARATOR, OPTIONAL_COMPOUND_FIX, Trie, TrieBuilder, WORD_SEPARATOR, buildITrieFromWords, buildTrie, buildTrieFast, consolidate, convertToBTrie, countNodes, countWords, createDictionaryLineParserMapper as createDictionaryLineParser, createTrieRoot, createTrieRootFromList, createWeightedMap, decodeFile, decodeTrie, defaultTrieInfo, defaultTrieInfo as defaultTrieOptions, editDistance, editDistanceWeighted, encodeITrieToBTrie, encodeTrieDataToBTrie, expandCharacterSet, findNode, has, hintedWalker, impersonateCollector, importTrie, insert, isCircular, isDefined, isWordTerminationNode, iterateTrie, iteratorTrieWords, mapDictionaryInformationToWeightMap, mergeDefaults, mergeOptionalWithDefaults, normalizeWord, normalizeWordForCaseInsensitive, normalizeWordToLowercase, orderTrie, parseDictionary, parseDictionaryLegacy, parseDictionaryLines, serializeTrie, suggestionCollector, trieNodeToRoot, walk, walker };
|
|
11255
|
+
export { CASE_INSENSITIVE_PREFIX, COMPOUND_FIX, CompoundWordsMethod, FLAG_WORD, FORBID_PREFIX, GTrie, GTrieNode, JOIN_SEPARATOR, OPTIONAL_COMPOUND_FIX, Trie, TrieBuilder, WORD_SEPARATOR, buildITrieFromWords, buildTrie, buildTrieFast, consolidate, convertToBTrie, countNodes, countWords, createDictionaryLineParserMapper as createDictionaryLineParser, createTrieRoot, createTrieRootFromList, createWeightedMap, decodeFile, decodeTrie, defaultTrieInfo, defaultTrieInfo as defaultTrieOptions, editDistance, editDistanceWeighted, encodeITrieToBTrie, encodeTrieDataToBTrie, expandCharacterSet, findNode, has, hintedWalker, impersonateCollector, importTrie, insert, isCircular, isDefined, isWordTerminationNode, iterateTrie, iteratorTrieWords, mapDictionaryInformationToWeightMap, mergeDefaults, mergeOptionalWithDefaults, normalizeWord, normalizeWordForCaseInsensitive, normalizeWordToLowercase, normalizeWordToLowercaseAndRemoveAccents, orderTrie, parseDictionary, parseDictionaryLegacy, parseDictionaryLines, serializeTrie, suggestionCollector, trieNodeToRoot, walk, walker };
|
|
11247
11256
|
|
|
11248
11257
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell-trie-lib",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.4.0",
|
|
4
4
|
"description": "Trie Data Structure to support cspell.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -59,19 +59,19 @@
|
|
|
59
59
|
"watch": "tsdown -w"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@cspell/cspell-performance-monitor": "10.
|
|
63
|
-
"@cspell/cspell-pipe": "10.
|
|
64
|
-
"@cspell/dict-cpp": "^7.1.
|
|
65
|
-
"@cspell/dict-en_us": "^4.4.
|
|
66
|
-
"@cspell/dict-es-es": "^3.0.
|
|
62
|
+
"@cspell/cspell-performance-monitor": "10.4.0",
|
|
63
|
+
"@cspell/cspell-pipe": "10.4.0",
|
|
64
|
+
"@cspell/dict-cpp": "^7.1.3",
|
|
65
|
+
"@cspell/dict-en_us": "^4.4.41",
|
|
66
|
+
"@cspell/dict-es-es": "^3.0.9",
|
|
67
67
|
"@cspell/dict-nl-nl": "^2.4.2",
|
|
68
68
|
"gensequence": "^8.0.8"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"@cspell/cspell-types": "10.
|
|
71
|
+
"@cspell/cspell-types": "10.4.0"
|
|
72
72
|
},
|
|
73
73
|
"engines": {
|
|
74
74
|
"node": ">=22.18.0"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "7e2bbb5e866c827ac5d2cf6b84bf3e1a016d0823"
|
|
77
77
|
}
|