cmpstr
Version:
CmpStr is a lightweight, fast and well performing package for calculating string similarity
51 lines (50 loc) • 1.9 kB
TypeScript
/**
* Jaro-Winkler Distance
* src/metric/JaroWinkler.ts
*
* @see https://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance
*
* The Jaro-Winkler distance is a string similarity metric that gives more weight
* to matching characters at the start of the strings. It is especially effective
* for short strings and typographical errors, and is widely used in record linkage
* and duplicate detection.
*
* @module Metric/JaroWinkler
* @author Paul Köhler (komed3)
* @license MIT
*/
import type { MetricInput, MetricOptions, MetricCompute } from '../utils/Types';
import { Metric } from './Metric';
export interface JaroWinklerRaw {
matchWindow: number;
matches: number;
transpos: number;
jaro: number;
prefix: number;
}
/**
* JaroWinklerDistance class extends the Metric class to implement the Jaro-Winkler algorithm.
*/
export declare class JaroWinklerDistance extends Metric<JaroWinklerRaw> {
/**
* Constructor for the JaroWinklerDistance class.
*
* Initializes the Jaro-Winkler metric with two input strings or
* arrays of strings and optional options.
*
* @param {MetricInput} a - First input string or array of strings
* @param {MetricInput} b - Second input string or array of strings
* @param {MetricOptions} [opt] - Options for the metric computation
*/
constructor(a: MetricInput, b: MetricInput, opt?: MetricOptions);
/**
* Calculates the Jaro-Winkler similarity between two strings.
*
* @param {string} a - First string
* @param {string} b - Second string
* @param {number} m - Length of the first string
* @param {number} n - Length of the second string
* @return {MetricCompute<JaroWinklerRaw>} - Object containing the similarity result and raw values
*/
protected compute(a: string, b: string, m: number, n: number): MetricCompute<JaroWinklerRaw>;
}