0
equates to no similarity and 1
is an exact match.
Definition
The Jaro distance \( d_j \) of two given strings \(s_1\) and \(s_2\) is
\begin{align}d_j = \begin{cases}0& & \text{if }m=0 \\\\{\frac {1}{3}}\left({\frac {m}{|s_{1}|}}+{\frac {m}{|s_{2}|}}+{\frac {m-t}{m}}\right)& & \text{otherwise}\end{cases}\end{align}
Where:
jaro
should be a function.
testString: assert(typeof jaro=='function','jaro
should be a function.');
- text: jaro("MARTHA", "MARHTA")
should return a number.
testString: assert(typeof jaro('MARTHA', 'MARHTA')=='number','jaro()
should return a number.');
- text: jaro("MARTHA", "MARHTA")
should return 0.9444444444444445
.
testString: assert.equal(jaro('MARTHA', 'MARHTA'), 0.9444444444444445,'jaro("MARTHA", "MARHTA")
should return 0.9444444444444445
.');
- text: jaro("DIXON", "DICKSONX")
should return 0.7666666666666666
.
testString: assert.equal(jaro('DIXON', 'DICKSONX'), 0.7666666666666666,'jaro("DIXON", "DICKSONX")
should return 0.7666666666666666
.');
- text: jaro("JELLYFISH", "SMELLYFISH")
should return 0.8962962962962964
.
testString: assert.equal(jaro('JELLYFISH', 'SMELLYFISH'), 0.8962962962962964,'jaro("JELLYFISH", "SMELLYFISH")
should return 0.8962962962962964
.');
- text: jaro("HELLOS", "CHELLO")
should return 0.888888888888889
.
testString: assert.equal(jaro('HELLOS', 'CHELLO'), 0.888888888888889,'jaro("HELLOS", "CHELLO")
should return 0.888888888888889
.');
- text: jaro("ABCD", "BCDA")
should return 0.8333333333333334
.
testString: assert.equal(jaro('ABCD', 'BCDA'), 0.8333333333333334,'jaro("ABCD", "BCDA")
should return 0.8333333333333334
.');
```