natural 8.2.0 → 8.2.2
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.
|
@@ -153,6 +153,7 @@ function levenshteinDistance (source, target, options) {
|
|
|
153
153
|
|
|
154
154
|
let lastColMatch = null
|
|
155
155
|
for (let row = 1; row <= sourceLength; row++) {
|
|
156
|
+
const sourceElement = source[row - 1]
|
|
156
157
|
if (isUnrestrictedDamerau) {
|
|
157
158
|
lastColMatch = null
|
|
158
159
|
}
|
|
@@ -160,7 +161,6 @@ function levenshteinDistance (source, target, options) {
|
|
|
160
161
|
const costToInsert = distanceMatrix[row][column - 1].cost + options.insertion_cost
|
|
161
162
|
const costToDelete = distanceMatrix[row - 1][column].cost + options.deletion_cost
|
|
162
163
|
|
|
163
|
-
const sourceElement = source[row - 1]
|
|
164
164
|
const targetElement = target[column - 1]
|
|
165
165
|
let costToSubstitute = distanceMatrix[row - 1][column - 1].cost
|
|
166
166
|
if (sourceElement !== targetElement) {
|
|
@@ -218,13 +218,13 @@ function levenshteinDistance (source, target, options) {
|
|
|
218
218
|
|
|
219
219
|
distanceMatrix[row][column] = { cost: minCostParent.cost, parentCell: minCostParent.coordinates }
|
|
220
220
|
|
|
221
|
-
if (isUnrestrictedDamerau) {
|
|
222
|
-
|
|
223
|
-
if (sourceElement === targetElement) {
|
|
224
|
-
lastColMatch = column
|
|
225
|
-
}
|
|
221
|
+
if (isUnrestrictedDamerau && sourceElement === targetElement) {
|
|
222
|
+
lastColMatch = column
|
|
226
223
|
}
|
|
227
224
|
}
|
|
225
|
+
if (isUnrestrictedDamerau) {
|
|
226
|
+
lastRowMap[sourceElement] = row
|
|
227
|
+
}
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
if (!options.search) {
|
|
@@ -29,7 +29,9 @@ class SoundEx extends Phonetic {
|
|
|
29
29
|
token = token.toLowerCase()
|
|
30
30
|
let transformed = this.condense(this.transform(token.substr(1, token.length - 1))) // anything that isn't a digit goes
|
|
31
31
|
// deal with duplicate INITIAL consonant SOUNDS
|
|
32
|
-
|
|
32
|
+
if (transformed.charAt(0) === this.transform(token.charAt(0))) {
|
|
33
|
+
transformed = transformed.slice(1)
|
|
34
|
+
}
|
|
33
35
|
return token.charAt(0).toUpperCase() + this.padRight0(transformed.replace(/\D/g, '')).substr(0, (maxLength && maxLength - 1) || 3)
|
|
34
36
|
}
|
|
35
37
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "natural",
|
|
3
3
|
"description": "General natural language (tokenizing, stemming (English, Russian, Spanish), part-of-speech tagging, sentiment analysis, classification, inflection, phonetics, tfidf, WordNet, jaro-winkler, Levenshtein distance, Dice's Coefficient) facilities for node.",
|
|
4
|
-
"version": "8.2.
|
|
4
|
+
"version": "8.2.2",
|
|
5
5
|
"homepage": "https://github.com/NaturalNode/natural",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|