cmpstr 3.0.3 → 3.1.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/README.md +2 -1
- package/dist/CmpStr.esm.js +2487 -4948
- package/dist/CmpStr.esm.js.map +1 -1
- package/dist/CmpStr.esm.min.js +3 -3
- package/dist/CmpStr.esm.min.js.map +1 -1
- package/dist/CmpStr.umd.js +2601 -5040
- package/dist/CmpStr.umd.js.map +1 -1
- package/dist/CmpStr.umd.min.js +3 -3
- package/dist/CmpStr.umd.min.js.map +1 -1
- package/dist/cjs/CmpStr.cjs +41 -405
- package/dist/cjs/CmpStr.cjs.map +1 -1
- package/dist/cjs/CmpStrAsync.cjs +38 -221
- package/dist/cjs/CmpStrAsync.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/metric/Cosine.cjs +1 -56
- package/dist/cjs/metric/Cosine.cjs.map +1 -1
- package/dist/cjs/metric/DamerauLevenshtein.cjs +2 -64
- package/dist/cjs/metric/DamerauLevenshtein.cjs.map +1 -1
- package/dist/cjs/metric/DiceSorensen.cjs +1 -56
- package/dist/cjs/metric/DiceSorensen.cjs.map +1 -1
- package/dist/cjs/metric/Hamming.cjs +2 -51
- package/dist/cjs/metric/Hamming.cjs.map +1 -1
- package/dist/cjs/metric/Jaccard.cjs +1 -48
- package/dist/cjs/metric/Jaccard.cjs.map +1 -1
- package/dist/cjs/metric/JaroWinkler.cjs +1 -53
- package/dist/cjs/metric/JaroWinkler.cjs.map +1 -1
- package/dist/cjs/metric/LCS.cjs +1 -54
- package/dist/cjs/metric/LCS.cjs.map +1 -1
- package/dist/cjs/metric/Levenshtein.cjs +2 -60
- package/dist/cjs/metric/Levenshtein.cjs.map +1 -1
- package/dist/cjs/metric/Metric.cjs +1 -261
- package/dist/cjs/metric/Metric.cjs.map +1 -1
- package/dist/cjs/metric/NeedlemanWunsch.cjs +4 -56
- package/dist/cjs/metric/NeedlemanWunsch.cjs.map +1 -1
- package/dist/cjs/metric/SmithWaterman.cjs +4 -58
- package/dist/cjs/metric/SmithWaterman.cjs.map +1 -1
- package/dist/cjs/metric/qGram.cjs +1 -55
- package/dist/cjs/metric/qGram.cjs.map +1 -1
- package/dist/cjs/phonetic/Caverphone.cjs +1 -78
- package/dist/cjs/phonetic/Caverphone.cjs.map +1 -1
- package/dist/cjs/phonetic/Cologne.cjs +1 -43
- package/dist/cjs/phonetic/Cologne.cjs.map +1 -1
- package/dist/cjs/phonetic/Metaphone.cjs +1 -76
- package/dist/cjs/phonetic/Metaphone.cjs.map +1 -1
- package/dist/cjs/phonetic/Phonetic.cjs +1 -261
- package/dist/cjs/phonetic/Phonetic.cjs.map +1 -1
- package/dist/cjs/phonetic/Soundex.cjs +1 -47
- package/dist/cjs/phonetic/Soundex.cjs.map +1 -1
- package/dist/cjs/root.cjs +49 -0
- package/dist/cjs/root.cjs.map +1 -0
- package/dist/cjs/utils/DeepMerge.cjs +8 -75
- package/dist/cjs/utils/DeepMerge.cjs.map +1 -1
- package/dist/cjs/utils/DiffChecker.cjs +2 -190
- package/dist/cjs/utils/DiffChecker.cjs.map +1 -1
- package/dist/cjs/utils/Filter.cjs +1 -112
- package/dist/cjs/utils/Filter.cjs.map +1 -1
- package/dist/cjs/utils/HashTable.cjs +1 -99
- package/dist/cjs/utils/HashTable.cjs.map +1 -1
- package/dist/cjs/utils/Normalizer.cjs +3 -94
- package/dist/cjs/utils/Normalizer.cjs.map +1 -1
- package/dist/cjs/utils/Pool.cjs +10 -105
- package/dist/cjs/utils/Pool.cjs.map +1 -1
- package/dist/cjs/utils/Profiler.cjs +1 -133
- package/dist/cjs/utils/Profiler.cjs.map +1 -1
- package/dist/cjs/utils/Registry.cjs +1 -89
- package/dist/cjs/utils/Registry.cjs.map +1 -1
- package/dist/cjs/utils/StructuredData.cjs +145 -0
- package/dist/cjs/utils/StructuredData.cjs.map +1 -0
- package/dist/cjs/utils/TextAnalyzer.cjs +1 -180
- package/dist/cjs/utils/TextAnalyzer.cjs.map +1 -1
- package/dist/esm/CmpStr.mjs +41 -405
- package/dist/esm/CmpStr.mjs.map +1 -1
- package/dist/esm/CmpStrAsync.mjs +38 -221
- package/dist/esm/CmpStrAsync.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/metric/Cosine.mjs +1 -56
- package/dist/esm/metric/Cosine.mjs.map +1 -1
- package/dist/esm/metric/DamerauLevenshtein.mjs +2 -64
- package/dist/esm/metric/DamerauLevenshtein.mjs.map +1 -1
- package/dist/esm/metric/DiceSorensen.mjs +1 -56
- package/dist/esm/metric/DiceSorensen.mjs.map +1 -1
- package/dist/esm/metric/Hamming.mjs +2 -51
- package/dist/esm/metric/Hamming.mjs.map +1 -1
- package/dist/esm/metric/Jaccard.mjs +1 -48
- package/dist/esm/metric/Jaccard.mjs.map +1 -1
- package/dist/esm/metric/JaroWinkler.mjs +1 -53
- package/dist/esm/metric/JaroWinkler.mjs.map +1 -1
- package/dist/esm/metric/LCS.mjs +1 -54
- package/dist/esm/metric/LCS.mjs.map +1 -1
- package/dist/esm/metric/Levenshtein.mjs +2 -60
- package/dist/esm/metric/Levenshtein.mjs.map +1 -1
- package/dist/esm/metric/Metric.mjs +1 -261
- package/dist/esm/metric/Metric.mjs.map +1 -1
- package/dist/esm/metric/NeedlemanWunsch.mjs +4 -56
- package/dist/esm/metric/NeedlemanWunsch.mjs.map +1 -1
- package/dist/esm/metric/SmithWaterman.mjs +4 -58
- package/dist/esm/metric/SmithWaterman.mjs.map +1 -1
- package/dist/esm/metric/qGram.mjs +1 -55
- package/dist/esm/metric/qGram.mjs.map +1 -1
- package/dist/esm/phonetic/Caverphone.mjs +1 -78
- package/dist/esm/phonetic/Caverphone.mjs.map +1 -1
- package/dist/esm/phonetic/Cologne.mjs +1 -43
- package/dist/esm/phonetic/Cologne.mjs.map +1 -1
- package/dist/esm/phonetic/Metaphone.mjs +1 -76
- package/dist/esm/phonetic/Metaphone.mjs.map +1 -1
- package/dist/esm/phonetic/Phonetic.mjs +1 -261
- package/dist/esm/phonetic/Phonetic.mjs.map +1 -1
- package/dist/esm/phonetic/Soundex.mjs +1 -47
- package/dist/esm/phonetic/Soundex.mjs.map +1 -1
- package/dist/esm/root.mjs +35 -0
- package/dist/esm/root.mjs.map +1 -0
- package/dist/esm/utils/DeepMerge.mjs +8 -76
- package/dist/esm/utils/DeepMerge.mjs.map +1 -1
- package/dist/esm/utils/DiffChecker.mjs +2 -190
- package/dist/esm/utils/DiffChecker.mjs.map +1 -1
- package/dist/esm/utils/Filter.mjs +1 -112
- package/dist/esm/utils/Filter.mjs.map +1 -1
- package/dist/esm/utils/HashTable.mjs +1 -99
- package/dist/esm/utils/HashTable.mjs.map +1 -1
- package/dist/esm/utils/Normalizer.mjs +3 -94
- package/dist/esm/utils/Normalizer.mjs.map +1 -1
- package/dist/esm/utils/Pool.mjs +10 -105
- package/dist/esm/utils/Pool.mjs.map +1 -1
- package/dist/esm/utils/Profiler.mjs +1 -133
- package/dist/esm/utils/Profiler.mjs.map +1 -1
- package/dist/esm/utils/Registry.mjs +1 -89
- package/dist/esm/utils/Registry.mjs.map +1 -1
- package/dist/esm/utils/StructuredData.mjs +143 -0
- package/dist/esm/utils/StructuredData.mjs.map +1 -0
- package/dist/esm/utils/TextAnalyzer.mjs +1 -180
- package/dist/esm/utils/TextAnalyzer.mjs.map +1 -1
- package/dist/types/CmpStr.d.ts +90 -8
- package/dist/types/CmpStrAsync.d.ts +82 -8
- package/dist/types/index.d.ts +3 -2
- package/dist/types/root.d.ts +39 -0
- package/dist/types/utils/Pool.d.ts +2 -2
- package/dist/types/utils/StructuredData.d.ts +162 -0
- package/dist/types/utils/Types.d.ts +35 -1
- package/package.json +63 -22
|
@@ -1,33 +1,9 @@
|
|
|
1
|
-
// CmpStr v3.0
|
|
1
|
+
// CmpStr v3.1.0 build-76aadb9-260117 by Paul Köhler @komed3 / MIT License
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var Phonetic = require('./Phonetic.cjs');
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Metaphone Phonetic Algorithm
|
|
8
|
-
* src/phonetic/Metaphone.ts
|
|
9
|
-
*
|
|
10
|
-
* @see https://en.wikipedia.org/wiki/Metaphone
|
|
11
|
-
*
|
|
12
|
-
* Metaphone is a phonetic algorithm for indexing words by their English pronunciation.
|
|
13
|
-
* It encodes words into a string of consonant symbols, allowing for the comparison of
|
|
14
|
-
* words based on their pronunciation rather than their spelling. Metaphone is more
|
|
15
|
-
* accurate than Soundex for English and is widely used in search, spell-checking,
|
|
16
|
-
* and fuzzy matching.
|
|
17
|
-
*
|
|
18
|
-
* This implementation uses a mapping and a comprehensive ruleset to efficiently
|
|
19
|
-
* transform input words into their Metaphone code. The algorithm drops or transforms
|
|
20
|
-
* letters according to context-sensitive rules, and only retains vowels at the start.
|
|
21
|
-
*
|
|
22
|
-
* @module Phonetic/Metaphone
|
|
23
|
-
* @author Paul Köhler (komed3)
|
|
24
|
-
* @license MIT
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* Metaphone class extends the Phonetic class to implement the Metaphone phonetic algorithm.
|
|
28
|
-
*/
|
|
29
6
|
class Metaphone extends Phonetic.Phonetic {
|
|
30
|
-
// Default options for the Metaphone phonetic algorithm
|
|
31
7
|
static default = {
|
|
32
8
|
map: 'en90',
|
|
33
9
|
delimiter: ' ',
|
|
@@ -35,49 +11,18 @@ class Metaphone extends Phonetic.Phonetic {
|
|
|
35
11
|
pad: '',
|
|
36
12
|
dedupe: false
|
|
37
13
|
};
|
|
38
|
-
/**
|
|
39
|
-
* Constructor for the Metaphone class.
|
|
40
|
-
*
|
|
41
|
-
* Initializes the Metaphone phonetic algorithm with the mapping and options.
|
|
42
|
-
*
|
|
43
|
-
* @param {PhoneticOptions} [opt] - Options for the Metaphone phonetic algorithm
|
|
44
|
-
*/
|
|
45
14
|
constructor(opt = {}) {
|
|
46
15
|
super('metaphone', opt);
|
|
47
16
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Generates the Metaphone code for a given word.
|
|
50
|
-
*
|
|
51
|
-
* @param {string} word - The input word to be converted into a Metaphone code
|
|
52
|
-
* @returns {string} - The generated Metaphone code
|
|
53
|
-
*/
|
|
54
17
|
encode(word) {
|
|
55
|
-
// Remove duplicate adjacent letters except for C
|
|
56
18
|
word = word.replace(/([A-BD-Z])\1+/gi, (m, c) => (c === 'C' ? m : c));
|
|
57
|
-
// Use the base implementation for rule/mapping application
|
|
58
19
|
return super.encode(word);
|
|
59
20
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Adjusts the Metaphone code by removing vowels except for the first letter.
|
|
62
|
-
*
|
|
63
|
-
* @param {string} code - The Metaphone code to be adjusted
|
|
64
|
-
* @returns {string} - The adjusted Metaphone code
|
|
65
|
-
*/
|
|
66
21
|
adjustCode(code) {
|
|
67
|
-
// Remove vowels except for the first letter
|
|
68
22
|
return code.slice(0, 1) + code.slice(1).replace(/[AEIOU]/g, '');
|
|
69
23
|
}
|
|
70
24
|
}
|
|
71
|
-
// Register the Metaphone algorithm in the phonetic registry
|
|
72
25
|
Phonetic.PhoneticRegistry.add('metaphone', Metaphone);
|
|
73
|
-
/**
|
|
74
|
-
* Register the Metaphone phonetic mapping for English.
|
|
75
|
-
*
|
|
76
|
-
* This version is based on the original BASIC implementation from 1990,
|
|
77
|
-
* written by Lawrence Philips.
|
|
78
|
-
*
|
|
79
|
-
* @see https://gist.github.com/Rostepher/b688f709587ac145a0b3
|
|
80
|
-
*/
|
|
81
26
|
Phonetic.PhoneticMappingRegistry.add('metaphone', 'en90', {
|
|
82
27
|
map: {
|
|
83
28
|
a: 'A',
|
|
@@ -108,62 +53,42 @@ Phonetic.PhoneticMappingRegistry.add('metaphone', 'en90', {
|
|
|
108
53
|
z: 'S'
|
|
109
54
|
},
|
|
110
55
|
ruleset: [
|
|
111
|
-
// Drop the first letter if the string begins with `AE`, `GN`, `KN`, `PN` or `WR`
|
|
112
56
|
{ char: 'a', position: 'start', next: ['e'], code: '' },
|
|
113
57
|
{ char: 'g', position: 'start', next: ['n'], code: '' },
|
|
114
58
|
{ char: 'k', position: 'start', next: ['n'], code: '' },
|
|
115
59
|
{ char: 'p', position: 'start', next: ['n'], code: '' },
|
|
116
60
|
{ char: 'w', position: 'start', next: ['r'], code: '' },
|
|
117
|
-
// Drop `B` if after `M` at the end of the string
|
|
118
61
|
{ char: 'b', position: 'end', prev: ['m'], code: '' },
|
|
119
|
-
// `C` transforms into `X` if followed by `H` or `IA`
|
|
120
62
|
{ char: 'c', next: ['h'], prevNot: ['s'], code: 'X' },
|
|
121
63
|
{ char: 'c', next: ['i'], next2: ['a'], code: 'X' },
|
|
122
|
-
// `C` transforms into `S` if followed by `E`, `I` or `Y`
|
|
123
64
|
{ char: 'c', next: ['e', 'i', 'y'], code: 'S' },
|
|
124
|
-
// `D` transforms into `J` if followed by `GE`, `GI` or `GY`
|
|
125
65
|
{ char: 'd', next: ['g'], next2: ['e', 'i', 'y'], code: 'J' },
|
|
126
|
-
// Drop `G` if followed by `H` and `H` is not at the end or before a vowel
|
|
127
66
|
{
|
|
128
67
|
char: 'g',
|
|
129
68
|
next: ['h'],
|
|
130
69
|
next2Not: ['', 'a', 'e', 'i', 'o', 'u'],
|
|
131
70
|
code: ''
|
|
132
71
|
},
|
|
133
|
-
// Drop `G` if followed by `N` or `NED` and is at the end of the string
|
|
134
72
|
{ char: 'g', trailing: 'n', code: '' },
|
|
135
73
|
{ char: 'g', trailing: 'ned', code: '' },
|
|
136
|
-
// `G` transforms into `J` if before `E`, `I` or `Y` and is not a `GG`
|
|
137
74
|
{ char: 'g', next: ['e', 'i', 'y'], prevNot: ['g'], code: 'J' },
|
|
138
|
-
// Drop `H` if after a vowel and not before a vowel
|
|
139
75
|
{
|
|
140
76
|
char: 'h',
|
|
141
77
|
prev: ['a', 'e', 'i', 'o', 'u'],
|
|
142
78
|
nextNot: ['a', 'e', 'i', 'o', 'u'],
|
|
143
79
|
code: ''
|
|
144
80
|
},
|
|
145
|
-
// Drop `H` if after `C`, `G`, `P`, `S` or `T`
|
|
146
81
|
{ char: 'h', prev: ['c', 'g', 'p', 's', 't'], code: '' },
|
|
147
|
-
// Drop `K` if after `C`
|
|
148
82
|
{ char: 'k', prev: ['c'], code: '' },
|
|
149
|
-
// `PH` transforms into `F`
|
|
150
83
|
{ char: 'p', next: ['h'], code: 'F' },
|
|
151
|
-
// `S` transforms into `X` if followed by `H`, `IA` or `IO`
|
|
152
84
|
{ char: 's', next: ['h'], code: 'X' },
|
|
153
85
|
{ char: 's', next: ['i'], next2: ['a', 'o'], code: 'X' },
|
|
154
|
-
// `T` transforms into `X` if followed by `IA` or `IO`
|
|
155
86
|
{ char: 't', next: ['i'], next2: ['a', 'o'], code: 'X' },
|
|
156
|
-
// `TH` transforms into `0` (zero)
|
|
157
87
|
{ char: 't', next: ['h'], code: '0' },
|
|
158
|
-
// Drop `T` if followed by `CH`
|
|
159
88
|
{ char: 't', next: ['c'], next2: ['h'], code: '' },
|
|
160
|
-
// Drop `W` if not followed by a vowel
|
|
161
89
|
{ char: 'w', nextNot: ['a', 'e', 'i', 'o', 'u'], code: '' },
|
|
162
|
-
// `WH` transforms into `W` if at the beginning of the string
|
|
163
90
|
{ char: 'h', leading: 'w', code: '' },
|
|
164
|
-
// `X` transforms into `S` if at the beginning
|
|
165
91
|
{ char: 'x', position: 'start', code: 'S' },
|
|
166
|
-
// Drop `Y` if not followed by a vowel
|
|
167
92
|
{ char: 'y', nextNot: ['a', 'e', 'i', 'o', 'u'], code: '' }
|
|
168
93
|
]
|
|
169
94
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Metaphone.cjs","sources":["../../../src/phonetic/Metaphone.ts"],"sourcesContent":[null],"names":["Phonetic","PhoneticRegistry","PhoneticMappingRegistry"],"mappings":";;;;;AAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;AAmBG,CAAA,CAAA;AAOH,CAAA,CAAA;;AAEG,CAAA,CAAA;AACG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CAAA,CAAA,CAAA,CAAO,CAAA,CAAE,CAAA,CAAA,CAAA,CAAI,CAAA,CAAE,CAAA,CAAA,CAAG,CAAA,CAAE;IAE3C,CAAA,CAAE,IAAI,CAAA,CAAE,CAAA,CAAA,CAAG,EAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAE,CAAE,CAAA,CAAA,CAAG,CAAA,CAAE,GAAG,CAAA,CAAE,CAAA,CAAA,CAAG,EAAE,CAAA,CAAA,CAAG,CAAA,CAAE,GAAG,CAAE,CAAA,CAAE,CAAA,CAAA,CAAA,CAAI,CAAA,CAAE,CAAA,CAAE,CAAA;AAC9D,CAAA,CAAA;AACJ,CAAA,CAAE;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// CmpStr v3.0
|
|
1
|
+
// CmpStr v3.1.0 build-76aadb9-260117 by Paul Köhler @komed3 / MIT License
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var DeepMerge = require('../utils/DeepMerge.cjs');
|
|
@@ -6,356 +6,146 @@ var Registry = require('../utils/Registry.cjs');
|
|
|
6
6
|
var HashTable = require('../utils/HashTable.cjs');
|
|
7
7
|
var Profiler = require('../utils/Profiler.cjs');
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Abstract Phonetic
|
|
11
|
-
* src/phonetic/Phonetic.ts
|
|
12
|
-
*
|
|
13
|
-
* @see https://en.wikipedia.org/wiki/Phonetic_algorithm
|
|
14
|
-
*
|
|
15
|
-
* A phonetic algorithm refers to a method for indexing words according to their
|
|
16
|
-
* pronunciation. When the algorithm relies on orthography, it is significantly
|
|
17
|
-
* influenced by the spelling conventions of the language for which it is intended:
|
|
18
|
-
* since the majority of phonetic algorithms were created for English, they tend
|
|
19
|
-
* to be less effective for indexing words in other languages.
|
|
20
|
-
*
|
|
21
|
-
* Phonetic search has numerous applications, and one of the initial use cases has
|
|
22
|
-
* been in trademark searches to verify that newly registered trademarks do not
|
|
23
|
-
* pose a risk of infringing upon existing trademarks due to their pronunciation.
|
|
24
|
-
*
|
|
25
|
-
* This module provides an abstract class for generating phonetic indices based
|
|
26
|
-
* on mappings, patterns and rules. It allows for the implementation of various
|
|
27
|
-
* phonetic algorithms by extending the abstract class.
|
|
28
|
-
*
|
|
29
|
-
* @module Phonetic
|
|
30
|
-
* @author Paul Köhler (komed3)
|
|
31
|
-
* @license MIT
|
|
32
|
-
*/
|
|
33
|
-
// Get the singleton profiler instance for performance monitoring
|
|
34
9
|
const profiler = Profiler.Profiler.getInstance();
|
|
35
|
-
/**
|
|
36
|
-
* Abstract class representing a phonetic algorithm.
|
|
37
|
-
*
|
|
38
|
-
* The protected methods `applyRules`, `encode`, `mapChar`, `equalLen`, `word2Chars`,
|
|
39
|
-
* `exitEarly`, `adjustCode`, `loop` and `loopAsync` can be overridden in subclasses
|
|
40
|
-
* to implement specific phonetic algorithms.
|
|
41
|
-
*
|
|
42
|
-
* @abstract
|
|
43
|
-
*/
|
|
44
10
|
class Phonetic {
|
|
45
|
-
// Cache for indexed words to avoid redundant calculations
|
|
46
11
|
static cache = new HashTable.HashTable();
|
|
47
|
-
/**
|
|
48
|
-
* Default phonetic options.
|
|
49
|
-
*
|
|
50
|
-
* This object contains default settings for phonetic algorithms,
|
|
51
|
-
* implemented in the subclass.
|
|
52
|
-
*/
|
|
53
12
|
static default;
|
|
54
|
-
// Phonetic algorithm name for identification
|
|
55
13
|
algo;
|
|
56
|
-
// Phonetic map and options for the algorithm
|
|
57
14
|
options;
|
|
58
15
|
map;
|
|
59
|
-
/**
|
|
60
|
-
* Static method to clear the cache of indexed words.
|
|
61
|
-
*/
|
|
62
16
|
static clear() {
|
|
63
17
|
this.cache.clear();
|
|
64
18
|
}
|
|
65
|
-
/**
|
|
66
|
-
* Constructor for the Phonetic class.
|
|
67
|
-
*
|
|
68
|
-
* Initializes the phonetic algorithm with the specified options and mapping.
|
|
69
|
-
* Options hierarchy: User input > mapping options > default
|
|
70
|
-
*
|
|
71
|
-
* @param {string} algo - The name of the algorithm (e.g. 'soundex')
|
|
72
|
-
* @param {PhoneticOptions} [opt] - Options for the phonetic algorithm
|
|
73
|
-
* @throws {Error} - If the requested mapping is not declared
|
|
74
|
-
*/
|
|
75
19
|
constructor(algo, opt = {}) {
|
|
76
|
-
// Get the phonetic default options
|
|
77
20
|
const defaults = this.constructor.default ?? {};
|
|
78
|
-
// Determine phonetic map ID from options or use defaults
|
|
79
21
|
const mapId = opt.map ?? defaults.map;
|
|
80
|
-
// If no algorithm is specified, throw an error
|
|
81
22
|
if (!mapId) throw new Error(`No mapping specified for phonetic algorithm`);
|
|
82
|
-
// Get the mapping based on the determined map ID
|
|
83
23
|
const map = PhoneticMappingRegistry.get(algo, mapId);
|
|
84
|
-
// If the mapping is not defined, throw an error
|
|
85
24
|
if (map === undefined)
|
|
86
25
|
throw new Error(`Requested mapping <${mapId}> is not declared`);
|
|
87
|
-
// Set the options by merging the default options with the provided ones
|
|
88
26
|
this.options = DeepMerge.merge(
|
|
89
27
|
DeepMerge.merge(defaults, map.options ?? {}),
|
|
90
28
|
opt
|
|
91
29
|
);
|
|
92
|
-
// Set the algorithm name and mapping
|
|
93
30
|
this.algo = algo;
|
|
94
31
|
this.map = map;
|
|
95
32
|
}
|
|
96
|
-
/**
|
|
97
|
-
* Applies patterns to a word based on the phonetic map.
|
|
98
|
-
*
|
|
99
|
-
* This method processes the word by applying all defined patterns in the
|
|
100
|
-
* phonetic map. It replaces occurrences of specified patterns with their
|
|
101
|
-
* corresponding replacements.
|
|
102
|
-
*
|
|
103
|
-
* @param {string} word - The input word to be processed
|
|
104
|
-
* @returns {string} - The modified word after applying all patterns
|
|
105
|
-
*/
|
|
106
33
|
applyPattern(word) {
|
|
107
34
|
const { patterns = [] } = this.map;
|
|
108
|
-
// If no patterns are provided, return the input
|
|
109
35
|
if (!patterns || !patterns.length) return word;
|
|
110
|
-
// Iterate over the patterns and replace all matches
|
|
111
36
|
for (const { pattern, replace, all = false } of patterns) {
|
|
112
|
-
// Search for the pattern in the word and replace it
|
|
113
|
-
// Use replaceAll if 'all' is true, otherwise use replace
|
|
114
37
|
word = word[all ? 'replaceAll' : 'replace'](pattern, replace);
|
|
115
38
|
}
|
|
116
|
-
// Return the modified word after applying all patterns
|
|
117
39
|
return word;
|
|
118
40
|
}
|
|
119
|
-
/**
|
|
120
|
-
* Applies phonetic rules to a character in a word context.
|
|
121
|
-
*
|
|
122
|
-
* This method is designed to be generic and efficient for all phonetic algorithms.
|
|
123
|
-
* It checks all rule types (prev, next, prevNot, nextNot, position, etc.) and
|
|
124
|
-
* returns either the appropriate code (string) or undefined.
|
|
125
|
-
*
|
|
126
|
-
* @param {string} char - The current character
|
|
127
|
-
* @param {number} i - The current position within the word
|
|
128
|
-
* @param {string[]} chars - The word as an array of characters
|
|
129
|
-
* @param {number} charLen - The total length of the word
|
|
130
|
-
* @returns {string|undefined} - The rule code or undefined if no rule applies
|
|
131
|
-
*/
|
|
132
41
|
applyRules(char, i, chars, charLen) {
|
|
133
42
|
const { ruleset = [] } = this.map;
|
|
134
|
-
// If no rules are provided, return undefined
|
|
135
43
|
if (!ruleset || !ruleset.length) return undefined;
|
|
136
|
-
// Get the surrounding characters
|
|
137
44
|
const prev = chars[i - 1] || '',
|
|
138
45
|
prev2 = chars[i - 2] || '';
|
|
139
46
|
const next = chars[i + 1] || '',
|
|
140
47
|
next2 = chars[i + 2] || '';
|
|
141
|
-
// Iterate over the rules to find a matching rule for the current character
|
|
142
48
|
for (const rule of ruleset) {
|
|
143
|
-
// Skip if the rule does not match the current character
|
|
144
49
|
if (rule.char && rule.char !== char) continue;
|
|
145
|
-
// Position in the word (start, middle, end)
|
|
146
50
|
if (rule.position === 'start' && i !== 0) continue;
|
|
147
51
|
if (rule.position === 'middle' && i > 0 && i < charLen) continue;
|
|
148
52
|
if (rule.position === 'end' && i !== charLen) continue;
|
|
149
|
-
// Previous character(s)
|
|
150
53
|
if (rule.prev && !rule.prev.includes(prev)) continue;
|
|
151
54
|
if (rule.prevNot && rule.prevNot.includes(prev)) continue;
|
|
152
55
|
if (rule.prev2 && !rule.prev2.includes(prev2)) continue;
|
|
153
56
|
if (rule.prev2Not && rule.prev2Not.includes(prev2)) continue;
|
|
154
|
-
// Following character(s)
|
|
155
57
|
if (rule.next && !rule.next.includes(next)) continue;
|
|
156
58
|
if (rule.nextNot && rule.nextNot.includes(next)) continue;
|
|
157
59
|
if (rule.next2 && !rule.next2.includes(next2)) continue;
|
|
158
60
|
if (rule.next2Not && rule.next2Not.includes(next2)) continue;
|
|
159
|
-
// Special case: Beginning of a word (e.g. chars.slice(0, n))
|
|
160
61
|
if (
|
|
161
62
|
rule.leading &&
|
|
162
63
|
!rule.leading.includes(chars.slice(0, rule.leading.length).join(''))
|
|
163
64
|
)
|
|
164
65
|
continue;
|
|
165
|
-
// Special case: end of word (e.g. chars.slice(-n))
|
|
166
66
|
if (
|
|
167
67
|
rule.trailing &&
|
|
168
68
|
!rule.trailing.includes(chars.slice(-rule.trailing.length).join(''))
|
|
169
69
|
)
|
|
170
70
|
continue;
|
|
171
|
-
// Check multiple characters (e.g. bigram/trigram)
|
|
172
71
|
if (rule.match && !rule.match.every((c, j) => chars[i + j] === c))
|
|
173
72
|
continue;
|
|
174
|
-
// If all conditions met, return the rule code
|
|
175
73
|
return rule.code;
|
|
176
74
|
}
|
|
177
|
-
// If no rule matched, return undefined
|
|
178
75
|
return undefined;
|
|
179
76
|
}
|
|
180
|
-
/**
|
|
181
|
-
* Generates the phonetic code for a given word.
|
|
182
|
-
*
|
|
183
|
-
* This method processes the word character by character, applying phonetic rules
|
|
184
|
-
* and mappings to generate a phonetic code.
|
|
185
|
-
*
|
|
186
|
-
* @param {string} word - The input word to be converted into a phonetic code
|
|
187
|
-
* @returns {string} - The generated phonetic code
|
|
188
|
-
*/
|
|
189
77
|
encode(word) {
|
|
190
78
|
const { map = {}, ignore = [] } = this.map;
|
|
191
|
-
// Apply patterns to the word before processing
|
|
192
|
-
// This allows for pre-processing of the word based on defined patterns
|
|
193
79
|
word = this.applyPattern(word);
|
|
194
|
-
// Get the characters of the word and its length
|
|
195
80
|
const chars = this.word2Chars(word);
|
|
196
81
|
const charLen = chars.length;
|
|
197
82
|
let code = '',
|
|
198
83
|
lastCode = null;
|
|
199
|
-
// Iterate over each character in the word
|
|
200
84
|
for (let i = 0; i < charLen; i++) {
|
|
201
85
|
const char = chars[i];
|
|
202
|
-
// Skip characters that are in the ignore list
|
|
203
86
|
if (ignore.includes(char)) continue;
|
|
204
|
-
// Convert the character to its phonetic code
|
|
205
87
|
const mapped = this.mapChar(char, i, chars, charLen, lastCode, map);
|
|
206
|
-
// If no code is generated, skip to the next character
|
|
207
88
|
if (mapped === undefined) continue;
|
|
208
|
-
// Append the generated code to the final code
|
|
209
89
|
((code += mapped), (lastCode = mapped));
|
|
210
|
-
// If the code length exceeds the specified limit, exit early
|
|
211
90
|
if (this.exitEarly(code, i)) break;
|
|
212
91
|
}
|
|
213
|
-
// Return the adjusted phonetic code
|
|
214
92
|
return this.adjustCode(code, chars);
|
|
215
93
|
}
|
|
216
|
-
/**
|
|
217
|
-
* Converts a character to its phonetic code based on the mapping and rules.
|
|
218
|
-
*
|
|
219
|
-
* @param {string} char - The current character
|
|
220
|
-
* @param {number} i - The current position within the word
|
|
221
|
-
* @param {string[]} chars - The word as an array of characters
|
|
222
|
-
* @param {number} charLen - The total length of the word
|
|
223
|
-
* @param {string|null} lastCode - The last code generated (to avoid duplicates)
|
|
224
|
-
* @param {Record<string, string>} map - The phonetic mapping
|
|
225
|
-
* @returns {string|undefined} - The phonetic code or undefined if no code applies
|
|
226
|
-
*/
|
|
227
94
|
mapChar(char, i, chars, charLen, lastCode, map) {
|
|
228
95
|
const { dedupe = true, fallback = undefined } = this.options;
|
|
229
|
-
// Apply phonetic rules to the character
|
|
230
|
-
// If no rules apply, use the mapping
|
|
231
|
-
// If the character is not in the mapping, return the fallback
|
|
232
96
|
const c = this.applyRules(char, i, chars, charLen) ?? map[char] ?? fallback;
|
|
233
|
-
// De-duplicate the code if necessary
|
|
234
97
|
return dedupe && c === lastCode ? undefined : c;
|
|
235
98
|
}
|
|
236
|
-
/**
|
|
237
|
-
* Ensures the phonetic code has a fixed length by padding or truncating.
|
|
238
|
-
*
|
|
239
|
-
* @param {string} input - The input string to be adjusted
|
|
240
|
-
* @returns {string} - The adjusted string with fixed length
|
|
241
|
-
*/
|
|
242
99
|
equalLen(input) {
|
|
243
100
|
const { length = -1, pad = '0' } = this.options;
|
|
244
101
|
return length === -1
|
|
245
102
|
? input
|
|
246
103
|
: (input + pad.repeat(length)).slice(0, length);
|
|
247
104
|
}
|
|
248
|
-
/**
|
|
249
|
-
* Converts a word into an array of characters.
|
|
250
|
-
*
|
|
251
|
-
* @param {string} word - The input word to be converted
|
|
252
|
-
* @returns {string[]} - An array of characters from the input word
|
|
253
|
-
*/
|
|
254
105
|
word2Chars(word) {
|
|
255
106
|
return word.toLowerCase().split('');
|
|
256
107
|
}
|
|
257
|
-
/**
|
|
258
|
-
* Determines whether to exit early based on the current phonetic code length.
|
|
259
|
-
*
|
|
260
|
-
* @param {string} code - The current phonetic code
|
|
261
|
-
* @param {number} i - The current index in the word
|
|
262
|
-
* @returns {boolean} - True if the code length exceeds the specified limit, false otherwise
|
|
263
|
-
*/
|
|
264
108
|
exitEarly(code, i) {
|
|
265
109
|
const { length = -1 } = this.options;
|
|
266
110
|
return length > 0 && code.length >= length;
|
|
267
111
|
}
|
|
268
|
-
/**
|
|
269
|
-
* Adjusts the phonetic code.
|
|
270
|
-
*
|
|
271
|
-
* @param {string} code - The phonetic code to be adjusted
|
|
272
|
-
* @param {string[]} chars - Characters to be removed from the code
|
|
273
|
-
* @returns {string} - The adjusted phonetic code
|
|
274
|
-
*/
|
|
275
112
|
adjustCode(code, chars) {
|
|
276
113
|
return code;
|
|
277
114
|
}
|
|
278
|
-
/**
|
|
279
|
-
* Processes an array of words to generate their phonetic indices.
|
|
280
|
-
*
|
|
281
|
-
* This method iterates over each word, generates its phonetic code,
|
|
282
|
-
* and ensures that the resulting codes are of equal length.
|
|
283
|
-
*
|
|
284
|
-
* @param {string[]} words - An array of words to be processed
|
|
285
|
-
* @returns {string[]} - An array of phonetic indices for the input words
|
|
286
|
-
*/
|
|
287
115
|
loop(words) {
|
|
288
116
|
const index = [];
|
|
289
|
-
// Loop over each word in the input array
|
|
290
117
|
for (const word of words) {
|
|
291
|
-
// Generate a cache key based on the algorithm and word
|
|
292
118
|
const key = Phonetic.cache.key(this.algo, [word]);
|
|
293
|
-
// If the key exists in the cache, return the cached result
|
|
294
|
-
// Otherwise, encode the word using the algorithm
|
|
295
119
|
const code =
|
|
296
120
|
Phonetic.cache.get(key || '') ??
|
|
297
121
|
(() => {
|
|
298
|
-
// Get the phonetic code for the word
|
|
299
122
|
const res = this.encode(word);
|
|
300
|
-
// If a key was generated, store the result in the cache
|
|
301
123
|
if (key) Phonetic.cache.set(key, res);
|
|
302
124
|
return res;
|
|
303
125
|
})();
|
|
304
|
-
// If a code is generated, add them to the index
|
|
305
126
|
if (code && code.length) index.push(this.equalLen(code));
|
|
306
127
|
}
|
|
307
128
|
return index;
|
|
308
129
|
}
|
|
309
|
-
/**
|
|
310
|
-
* Asynchronously processes an array of words to generate their phonetic indices.
|
|
311
|
-
*
|
|
312
|
-
* This method iterates over each word, generates its phonetic code asynchronously,
|
|
313
|
-
* and ensures that the resulting codes are of equal length.
|
|
314
|
-
*
|
|
315
|
-
* @param {string[]} words - An array of words to be processed
|
|
316
|
-
* @returns {Promise<string[]>} - A promise that resolves to an array of phonetic indices for the input words
|
|
317
|
-
*/
|
|
318
130
|
async loopAsync(words) {
|
|
319
131
|
const index = [];
|
|
320
|
-
// Loop over each word in the input array
|
|
321
132
|
for (const word of words) {
|
|
322
|
-
// Get the phonetic code for the word asynchronously
|
|
323
133
|
const code = await Promise.resolve(this.encode(word));
|
|
324
|
-
// If a code is generated, add them to the index
|
|
325
134
|
if (code && code.length) index.push(this.equalLen(code));
|
|
326
135
|
}
|
|
327
136
|
return index;
|
|
328
137
|
}
|
|
329
|
-
/**
|
|
330
|
-
* Get the name of the phonetic algorithm.
|
|
331
|
-
*
|
|
332
|
-
* @returns {string} - The name of the algorithm
|
|
333
|
-
*/
|
|
334
138
|
getAlgoName() {
|
|
335
139
|
return this.algo;
|
|
336
140
|
}
|
|
337
|
-
/**
|
|
338
|
-
* Generates a phonetic index for the given input string.
|
|
339
|
-
*
|
|
340
|
-
* @param {string} input - The input string to be indexed
|
|
341
|
-
* @returns {string[]} - An array of phonetic indices for the input words
|
|
342
|
-
*/
|
|
343
141
|
getIndex(input) {
|
|
344
142
|
const { delimiter = ' ' } = this.options;
|
|
345
|
-
// Split the input string by the specified delimiter and loop over it
|
|
346
143
|
return profiler.run(() =>
|
|
347
144
|
this.loop(input.split(delimiter).filter(Boolean)).filter(Boolean)
|
|
348
145
|
);
|
|
349
146
|
}
|
|
350
|
-
/**
|
|
351
|
-
* Asynchronously generates a phonetic index for the given input string.
|
|
352
|
-
*
|
|
353
|
-
* @param {string} input - The input string to be indexed
|
|
354
|
-
* @returns {Promise<string[]>} - A promise that resolves to an array of phonetic indices for the input words
|
|
355
|
-
*/
|
|
356
147
|
async getIndexAsync(input) {
|
|
357
148
|
const { delimiter = ' ' } = this.options;
|
|
358
|
-
// Split the input string by the specified delimiter and loop over it asynchronously
|
|
359
149
|
return (
|
|
360
150
|
await profiler.runAsync(
|
|
361
151
|
async () => await this.loopAsync(input.split(delimiter).filter(Boolean))
|
|
@@ -363,35 +153,11 @@ class Phonetic {
|
|
|
363
153
|
).filter(Boolean);
|
|
364
154
|
}
|
|
365
155
|
}
|
|
366
|
-
/**
|
|
367
|
-
* Phonetic registry service for managing phonetic implementations.
|
|
368
|
-
*
|
|
369
|
-
* This registry allows for dynamic registration and retrieval of phonetic classes,
|
|
370
|
-
* enabling the use of various phonetic algorithms in a consistent manner.
|
|
371
|
-
*/
|
|
372
156
|
const PhoneticRegistry = Registry.Registry('phonetic', Phonetic);
|
|
373
|
-
/**
|
|
374
|
-
* Phonetic Mapping Service
|
|
375
|
-
*
|
|
376
|
-
* This service provides a simple interface to manage phonetic mappings across
|
|
377
|
-
* different phonetic algorithms. It allows adding, removing, checking existence,
|
|
378
|
-
* retrieving, and listing phonetic mappings for specified algorithms.
|
|
379
|
-
*/
|
|
380
157
|
const PhoneticMappingRegistry = (() => {
|
|
381
|
-
// Create a registry object to hold mappings
|
|
382
158
|
const mappings = Object.create(null);
|
|
383
|
-
// Helper function to retrieve mappings for a specific algorithm
|
|
384
159
|
const maps = (algo) => (mappings[algo] ||= Object.create(null));
|
|
385
160
|
return {
|
|
386
|
-
/**
|
|
387
|
-
* Adds a phonetic mapping for a specific algorithm and ID.
|
|
388
|
-
*
|
|
389
|
-
* @param {string} algo - The phonetic algorithm identifier (e.g., 'soundex', 'metaphone')
|
|
390
|
-
* @param {string} id - The unique identifier for the mapping
|
|
391
|
-
* @param {PhoneticMap} map - The phonetic map to be added, containing rules and mappings
|
|
392
|
-
* @param {boolean} [update=false] - Whether to allow overwriting an existing entry
|
|
393
|
-
* @throws {Error} If the mapping name already exists and update is false
|
|
394
|
-
*/
|
|
395
161
|
add(algo, id, map, update = false) {
|
|
396
162
|
const mappings = maps(algo);
|
|
397
163
|
if (!update && id in mappings)
|
|
@@ -400,41 +166,15 @@ const PhoneticMappingRegistry = (() => {
|
|
|
400
166
|
);
|
|
401
167
|
mappings[id] = map;
|
|
402
168
|
},
|
|
403
|
-
/**
|
|
404
|
-
* Removes a phonetic mapping for a specific algorithm and ID.
|
|
405
|
-
*
|
|
406
|
-
* @param {string} algo - The phonetic algorithm identifier
|
|
407
|
-
* @param {string} id - The unique identifier for the mapping to be removed
|
|
408
|
-
*/
|
|
409
169
|
remove(algo, id) {
|
|
410
170
|
delete maps(algo)[id];
|
|
411
171
|
},
|
|
412
|
-
/**
|
|
413
|
-
* Checks if a phonetic mapping exists for a specific algorithm and ID.
|
|
414
|
-
*
|
|
415
|
-
* @param {string} algo - The phonetic algorithm identifier
|
|
416
|
-
* @param {string} id - The unique identifier for the mapping to check
|
|
417
|
-
* @returns {boolean} - Returns true if the mapping exists, false otherwise
|
|
418
|
-
*/
|
|
419
172
|
has(algo, id) {
|
|
420
173
|
return id in maps(algo);
|
|
421
174
|
},
|
|
422
|
-
/**
|
|
423
|
-
* Retrieves a phonetic mapping for a specific algorithm and ID.
|
|
424
|
-
*
|
|
425
|
-
* @param {string} algo - The phonetic algorithm identifier
|
|
426
|
-
* @param {string} id - The unique identifier for the mapping to retrieve
|
|
427
|
-
* @returns {PhoneticMap | undefined} - Returns the phonetic map if found, otherwise undefined
|
|
428
|
-
*/
|
|
429
175
|
get(algo, id) {
|
|
430
176
|
return maps(algo)[id];
|
|
431
177
|
},
|
|
432
|
-
/**
|
|
433
|
-
* Lists all phonetic mappings for a specific algorithm.
|
|
434
|
-
*
|
|
435
|
-
* @param {string} algo - The phonetic algorithm identifier
|
|
436
|
-
* @returns {string[]} - Returns an array of mapping IDs for the specified algorithm
|
|
437
|
-
*/
|
|
438
178
|
list(algo) {
|
|
439
179
|
return Object.keys(maps(algo));
|
|
440
180
|
}
|