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