Socket
Socket
Sign inDemoInstall

hermetrics

Package Overview
Dependencies
0
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.10 to 1.1.11

2

dist/hermetrics/metric.js

@@ -26,3 +26,3 @@ "use strict";

normalize(x, low = 0, high = 1) {
//const norm : number = 0
// const norm : number = 0
if (high <= low) {

@@ -29,0 +29,0 @@ return 0;

{
"name": "hermetrics",
"version": "1.1.10",
"version": "1.1.11",
"description": "Javascript version of hermetrics.py",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -18,2 +18,4 @@ ![](https://res.cloudinary.com/dlacw28m9/image/upload/v1583255567/hermetrics.js_wmbdhh.png)

* [Levenshtein](#levenshtein)
* [Jaro](#jaro)
* [Jaro-Winkler](#jaro-winkler)
* Hamming (work in progress)

@@ -24,4 +26,2 @@ * OSA (work in progress)

* Dice (work in progress)
* Jaro (work in progress)
* Jaro-Winkler (work in progress)
* Metric comparator (work in progress)

@@ -97,6 +97,6 @@

|maxDistance| Returns the maximum value of the distance between source and target given a specific cost for edit operations. The default method just return 1 given source and target don't have both length=0, in that case just return 0. |
|minDistance| *work in progress* |
|normalize|*work in progress*|
|normalized distance|*work in progress*|
|similarity|*work in progress*|
|minDistance| Return 0.|
| normalize | This method is used to scale a value between two limits, usually those obtained by maxDistance and minDistance, to the (0,1) range. Unlike the other methods, normalize doesn't receive the usual arguments (source, target and cost), instead receive the following: x. The value to be normalized. low=0. The minimum value for the normalization, usually obtained with minDistance method. high=1. The maximum value for the normalization, usually obtained with maxDistance method. |
| normalize distance | Scale the distance between source and target for specific cost to the (0,1) range using maxDistance, minDistance and normalize. |
| similarity | Computes how similar are source and target given a specific cost. By default defined as 1 - normalizedDistance so the result is also in the (0,1) range. |

@@ -107,2 +107,8 @@

## Jaro metric <a name="jaro"></a>
Jaro distance is based on the matching characters present on two strings and the number of transpositions between them. A matching occurs when a character of a string is present on the other string but in a position no further away that certain threshold based on the lenght of the strings. The Jaro distance is normalized.
## Jaro-Winkler <a name="jaro-winkler"></a>
Extension of Jaro distance with emphasis on the first characters of the strings, so strings that have matching characters on the beginning have more similarity than those that have matching characters at the end. This metric depends on an additional parameter p (with 0<=p<=0.25 and default p=0.1) that is a weighting factor for additional score obtained for matching characters at the beginning of the strings..
## Contributors

@@ -109,0 +115,0 @@

@@ -6,4 +6,3 @@ import LevenshteinCostOptions from '../interfaces/levenshtein-opts.interface'

constructor (name = 'Generic')
{
constructor (name = 'Generic') {
this._name = name

@@ -15,27 +14,22 @@ }

*/
public distance (source: string, target: string, { deletionCost, insertionCost, substitutionCost }: LevenshteinCostOptions = {}): number
{
public distance (source: string, target: string, { deletionCost, insertionCost, substitutionCost }: LevenshteinCostOptions = {}): number {
return source === target ? 0 : 1
}
public maxDistance (source: string, target: string, { deletionCost, insertionCost, substitutionCost }: LevenshteinCostOptions = {}): number
{
public maxDistance (source: string, target: string, { deletionCost, insertionCost, substitutionCost }: LevenshteinCostOptions = {}): number {
return (source.length === 0 && target.length === 0) ? 0 : 1
}
/**
*
* @param source
* @param target
* @param cost
*
* @param source
* @param target
* @param cost
*/
public minDistance (source: string, target: string, { deletionCost, insertionCost, substitutionCost }: LevenshteinCostOptions = {}) : number
{
public minDistance (source: string, target: string, { deletionCost, insertionCost, substitutionCost }: LevenshteinCostOptions = {}): number {
return 0
}
public normalize(x: number, low: number = 0, high: number = 1): number
{
//const norm : number = 0
public normalize (x: number, low: number = 0, high: number = 1): number {
// const norm : number = 0
if (high <= low) {

@@ -54,7 +48,6 @@ return 0

public normalizedDistance (source: string, target: string, {deletionCost, insertionCost, substitutionCost} : LevenshteinCostOptions = {}) : number
{
const x : number = this.distance(source, target, {deletionCost, insertionCost, substitutionCost})
const min: number= this.minDistance(source, target, {deletionCost, insertionCost, substitutionCost})
const max: number = this.maxDistance(source, target, {deletionCost, insertionCost, substitutionCost})
public normalizedDistance (source: string, target: string, { deletionCost, insertionCost, substitutionCost }: LevenshteinCostOptions = {}): number {
const x: number = this.distance(source, target, { deletionCost, insertionCost, substitutionCost })
const min: number = this.minDistance(source, target, { deletionCost, insertionCost, substitutionCost })
const max: number = this.maxDistance(source, target, { deletionCost, insertionCost, substitutionCost })
return this.normalize(x, min, max)

@@ -61,0 +54,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc