0.2.0 - Mid migration

This commit is contained in:
Daniel Mason 2022-04-25 14:47:15 +12:00
parent 139e6a915e
commit 7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions

77
web/node_modules/damerau-levenshtein/CHANGELOG.md generated vendored Normal file
View file

@ -0,0 +1,77 @@
# Change Log
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/). This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
## [1.0.7] - 2021-05-05
Fixed:
- The script/update-changelog.sh wouldn't work without gsed in path
Security:
- Upgrade lodash (transitive development dependency) #17
- Upgrade yargs/y18n (transitive development dependency) #18
## [1.0.6] - 2020-01-27
Changed:
- Upgrade lodash to version 4.17.15 #16
## [1.0.5] - 2019-05-09
Changed:
- Upgrade Mocha to version 6.1.4 #12 by @whyboris
- Example use in README.md by @whyboris
## [1.0.4] - 2017-03-24
Fixed:
- Fails in strict mode #7 by @gilly3
## [1.0.3] - 2016-09-26
Fixed:
- A title of this document :P
Added:
- List of contributors
- Bugs URL
- Git repository URL
## [1.0.2] - 2016-09-26
Fixed:
- Similarity 0 returned for equal strings #4 by @tad-lispy
## [1.0.1] - 2016-09-12
Fixed:
- Wrong results for transposition #2 by @g-adolph
Added:
- First unit test by @g-adolph
- A Change Log :) by @tad-lispy
## [1.0.0] - 2016-02-23
Fixed:
- Update README to match the actual output by @gilly3
## [0.1.3] - 2013-09-02
Fixed:
- Clear matrix on each call @tad-lispy
- Always return an object @tad-lispy
## [0.1.2] - 2013-08-29
Added:
- ReadMe
## [0.1.1] - 2013-08-28
Added:
- Initial working release @tad-lispy

25
web/node_modules/damerau-levenshtein/LICENSE generated vendored Normal file
View file

@ -0,0 +1,25 @@
BSD 2-Clause License
Copyright (c) 2018, Tadeusz Łazurski
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

47
web/node_modules/damerau-levenshtein/README.md generated vendored Normal file
View file

@ -0,0 +1,47 @@
[![NPM](https://nodei.co/npm/damerau-levenshtein.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/damerau-levenshtein/)
It provides a function that takes two string arguments and returns a hash like this:
``` javascript
{
steps: 5, // Levenstein demerau distance
relative: 0.7, // steps / length of the longer string
similarity: 0.3 // 1 - relative
}
```
## Install
```sh
npm install damerau-levenshtein
```
## Use with ES6 modules
```js
import * as levenshtien from 'damerau-levenshtein';
const lev = levenshtien('hello world', 'Hello World!');
// { steps: 4, relative: 0.3076923076923077, similarity: 0.6923076923076923 }
```
Please see [tests](./test/test.js) for more insights.
## Use with TypeScript
```ts
import * as levenshtien from 'damerau-levenshtein';
interface LevenshteinResponse {
steps: number;
relative: number;
similarity: number;
}
const lev: LevenshteinResponse = levenshtien('hello world', 'Hello World!');
console.log(lev.steps);
// 2
console.log(lev.foo);
// TypeScript Error: Property 'foo' does not exist on type 'LevenshteinResponse'.
```

72
web/node_modules/damerau-levenshtein/index.js generated vendored Normal file
View file

@ -0,0 +1,72 @@
// TheSpanishInquisition
// Cache the matrix. Note that if you not pass a limit this implementation will use a dynamically calculate one.
module.exports = function(__this, that, limit) {
var thisLength = __this.length,
thatLength = that.length,
matrix = [];
// If the limit is not defined it will be calculate from this and that args.
limit = (limit || ((thatLength > thisLength ? thatLength : thisLength)))+1;
for (var i = 0; i < limit; i++) {
matrix[i] = [i];
matrix[i].length = limit;
}
for (i = 0; i < limit; i++) {
matrix[0][i] = i;
}
if (Math.abs(thisLength - thatLength) > (limit || 100)){
return prepare (limit || 100);
}
if (thisLength === 0){
return prepare (thatLength);
}
if (thatLength === 0){
return prepare (thisLength);
}
// Calculate matrix.
var j, this_i, that_j, cost, min, t;
for (i = 1; i <= thisLength; ++i) {
this_i = __this[i-1];
// Step 4
for (j = 1; j <= thatLength; ++j) {
// Check the jagged ld total so far
if (i === j && matrix[i][j] > 4) return prepare (thisLength);
that_j = that[j-1];
cost = (this_i === that_j) ? 0 : 1; // Step 5
// Calculate the minimum (much faster than Math.min(...)).
min = matrix[i - 1][j ] + 1; // Deletion.
if ((t = matrix[i ][j - 1] + 1 ) < min) min = t; // Insertion.
if ((t = matrix[i - 1][j - 1] + cost) < min) min = t; // Substitution.
// Update matrix.
matrix[i][j] = (i > 1 && j > 1 && this_i === that[j-2] && __this[i-2] === that_j && (t = matrix[i-2][j-2]+cost) < min) ? t : min; // Transposition.
}
}
return prepare (matrix[thisLength][thatLength]);
/**
*
*/
function prepare(steps) {
var length = Math.max(thisLength, thatLength)
var relative = length === 0
? 0
: (steps / length);
var similarity = 1 - relative
return {
steps: steps,
relative: relative,
similarity: similarity
};
}
};

36
web/node_modules/damerau-levenshtein/package.json generated vendored Normal file
View file

@ -0,0 +1,36 @@
{
"name": "damerau-levenshtein",
"version": "1.0.7",
"description": "Damerau - Levenshtein distance by The Spanish Inquisition + relative distance",
"main": "index.js",
"scripts": {
"test": "mocha --use_strict",
"version": "scripts/update-changelog.sh"
},
"keywords": [
"Damerau-Levenshtein",
"Damerau",
"Levenshtein",
"distance",
"compare",
"relative"
],
"author": "The Spanish Inquisition",
"contributors": [
"Tadeusz Łazurski (https://tad-lispy.com/)",
"Gustavo Marques Adolph",
"Ivan Gilchrist <github@jumpingfishes.com> (http://jumpingfishes.com)",
"Boris Yakubchik (http://dev.yboris.com/)"
],
"license": "BSD-2-Clause",
"devDependencies": {
"mocha": "^6.1.4"
},
"repository": {
"type": "git",
"url": "https://github.com/tad-lispy/node-damerau-levenshtein.git"
},
"bugs": {
"url": "https://github.com/tad-lispy/node-damerau-levenshtein/issues"
}
}

View file

@ -0,0 +1,21 @@
#! /usr/bin/env bash
set -euo pipefail
# To make it work on OSX (provided gnu-sed in installed)
if type gsed
then
alias sed=gsed
fi
version=$(jq --raw-output ' .version ' "package.json")
date=$(date +%Y-%m-%d)
sed \
--regexp-extended \
--in-place="" \
"s$^## \[Unreleased\]$\## [Unreleased\]\n\n\n## [${version}] - ${date}$" \
CHANGELOG.md
git add CHANGELOG.md

168
web/node_modules/damerau-levenshtein/test/test.js generated vendored Normal file
View file

@ -0,0 +1,168 @@
var levenshtien = require("./../index");
var assert = require("assert");
describe("Damerau - Levenshtein", function() {
describe("Equality", function() {
it("returns 0 steps for equal strings", function() {
assert.deepEqual(levenshtien("test", "test"), {
steps: 0,
relative: 0,
similarity: 1
});
});
});
describe("Additions", function() {
it("returns 1 step when appending one char", function() {
assert.deepEqual(levenshtien("test", "tests"), {
steps: 1,
relative: 1 / 5,
similarity: 1 - 1 / 5
});
});
it("returns 1 step when prepending one char", function() {
assert.deepEqual(levenshtien("test", "stest"), {
steps: 1,
relative: 1 / 5,
similarity: 1 - 1 / 5
});
});
it("returns 2 steps when appending two char", function() {
assert.deepEqual(levenshtien("test", "mytest"), {
steps: 2,
relative: 2 / 6,
similarity: 1 - 2 / 6
});
});
it("returns 7 steps when appending seven char", function() {
assert.deepEqual(levenshtien("test", "mycrazytest"), {
steps: 7,
relative: 7 / 11,
similarity: 1 - 7 / 11
});
});
it("returns 9 steps when prepend two chars and append seven chars", function() {
assert.deepEqual(levenshtien("test", "mytestiscrazy"), {
steps: 9,
relative: 9 / 13,
similarity: 1 - 9 / 13
});
});
});
describe("Addition of repeated chars", function() {
it("returns 1 step when repeating a character", function() {
assert.deepEqual(levenshtien("test", "teest"), {
steps: 1,
relative: 1 / 5,
similarity: 1 - 1 / 5
});
});
it("returns 2 step when repeating a character twice", function() {
assert.deepEqual(levenshtien("test", "teeest"), {
steps: 2,
relative: 2 / 6,
similarity: 1 - 2 / 6
});
});
});
describe("#Deletion", function() {
it("returns 1 step when removing one char", function() {
assert.deepEqual(levenshtien("test", "tst"), {
steps: 1,
relative: 1 / 4,
similarity: 1 - 1 / 4
});
});
});
describe("Transposition", function() {
it("returns 1 step when transposing one char", function() {
assert.deepEqual(levenshtien("test", "tset"), {
steps: 1,
relative: 1 / 4,
similarity: 1 - 1 / 4
});
});
});
describe("Addition with transposition", function() {
it("returns 2 step when transposing one char and append another", function() {
assert.deepEqual(levenshtien("test", "tsets"), {
steps: 2,
relative: 2 / 5,
similarity: 1 - 2 / 5
});
});
it("returns 2 step when transposing a char and repeating it", function() {
assert.deepEqual(levenshtien("test", "tsset"), {
steps: 2,
relative: 2 / 5,
similarity: 1 - 2 / 5
});
});
});
describe("Transposition of multiple chars", function() {
it("returns 1 step when transposing two neighbouring characters", function() {
assert.deepEqual(levenshtien("banana", "banaan"), {
steps: 1,
relative: 1 / 6,
similarity: 1 - 1 / 6
});
});
it("returns 2 step when transposing two neighbouring characters by two places", function() {
assert.deepEqual(levenshtien("banana", "nabana"), {
steps: 2,
relative: 2 / 6,
similarity: 1 - 2 / 6
});
});
it("returns 2 step when transposing two pairs of characters", function() {
assert.deepEqual(levenshtien("banana", "abnaan"), {
steps: 2,
relative: 2 / 6,
similarity: 1 - 2 / 6
});
});
});
describe("Empty strings", function() {
it("returns 0 step and 0 relative when both are empty", function() {
assert.deepEqual(levenshtien("", ""), {
steps: 0,
relative: 0,
similarity: 1
});
});
it("returns steps equal to first string lenght when second string is empty", function() {
assert.deepEqual(levenshtien("test", ""), {
steps: 4,
relative: 4 / 4,
similarity: 0
});
});
it("returns steps equal to second string lenght when first string is empty", function() {
assert.deepEqual(levenshtien("", "test"), {
steps: 4,
relative: 1,
similarity: 0
});
});
});
});