[go: up one dir, main page]

Jump to content

Jaro–Winkler distance: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
Tdpa1 (talk | contribs)
Definition: Clarify that "further than" means "further than ... positions apart"
Line 26: Line 26:
* <math>t</math> is half the number of ''transpositions'' (see below).
* <math>t</math> is half the number of ''transpositions'' (see below).


Two characters from <math>s_1</math> and <math>s_2</math> respectively, are considered ''matching'' only if they are the same and not farther than <math>\left\lfloor\frac{\max(|s_1|,|s_2|)}{2}\right\rfloor-1</math>.
Two characters from <math>s_1</math> and <math>s_2</math> respectively, are considered ''matching'' only if they are the same and not farther than <math>\left\lfloor\frac{\max(|s_1|,|s_2|)}{2}\right\rfloor-1</math> characters apart.


Each character of <math>s_1</math> is compared with all its matching characters in <math>s_2</math>. The number of matching (but different sequence order) characters divided by 2 defines the number of ''transpositions''.
Each character of <math>s_1</math> is compared with all its matching characters in <math>s_2</math>. The number of matching (but different sequence order) characters divided by 2 defines the number of ''transpositions''.
For example, in comparing CRATE with TRACE, only 'R' 'A' 'E' are the matching characters, i.e. m=3. Although 'C', 'T' appear in both strings, they are farther than 1 (the result of <math>\lfloor\tfrac{5}{2}\rfloor - 1</math>). Therefore, t=0 . In DwAyNE versus DuANE the matching letters are already in the same order D-A-N-E, so no transpositions are needed.
For example, in comparing CRATE with TRACE, only 'R' 'A' 'E' are the matching characters, i.e. m=3. Although 'C', 'T' appear in both strings, they are farther apart than 1 (the result of <math>\lfloor\tfrac{5}{2}\rfloor - 1</math>). Therefore, t=0 . In DwAyNE versus DuANE the matching letters are already in the same order D-A-N-E, so no transpositions are needed.


=== Jaro–Winkler Similarity ===
=== Jaro–Winkler Similarity ===

Revision as of 15:06, 7 July 2020

In computer science and statistics, the Jaro–Winkler distance is a string metric measuring an edit distance between two sequences. It is a variant proposed in 1990 by William E. Winkler of the Jaro distance metric (1989, Matthew A. Jaro).

The Jaro–Winkler distance uses a prefix scale which gives more favourable ratings to strings that match from the beginning for a set prefix length .

The lower the Jaro–Winkler distance for two strings is, the more similar the strings are. The score is normalized such that 0 means an exact match and 1 means there is no similarity. The Jaro–Winkler similarity is the inversion, (1 − Jaro–Winkler distance).

Although often referred to as a distance metric, the Jaro–Winkler distance is not a metric in the mathematical sense of that term because it does not obey the triangle inequality.

Definition

Jaro Similarity

The Jaro Similarity of two given strings and is

Where:

  • is the length of the string ;
  • is the number of matching characters (see below);
  • is half the number of transpositions (see below).

Two characters from and respectively, are considered matching only if they are the same and not farther than characters apart.

Each character of is compared with all its matching characters in . The number of matching (but different sequence order) characters divided by 2 defines the number of transpositions. For example, in comparing CRATE with TRACE, only 'R' 'A' 'E' are the matching characters, i.e. m=3. Although 'C', 'T' appear in both strings, they are farther apart than 1 (the result of ). Therefore, t=0 . In DwAyNE versus DuANE the matching letters are already in the same order D-A-N-E, so no transpositions are needed.

Jaro–Winkler Similarity

Jaro–Winkler similarity uses a prefix scale which gives more favorable ratings to strings that match from the beginning for a set prefix length . Given two strings and , their Jaro–Winkler similarity is:

where:

  • is the Jaro similarity for strings and
  • is the length of common prefix at the start of the string up to a maximum of four characters
  • is a constant scaling factor for how much the score is adjusted upwards for having common prefixes. should not exceed 0.25, otherwise the similarity could become larger than 1. The standard value for this constant in Winkler's work is

The Jaro-Winkler distance is defined as .

Although often referred to as a distance metric, the Jaro–Winkler distance is not a metric in the mathematical sense of that term because it does not obey the triangle inequality.[1] The Jaro–Winkler distance also does not satisfy the identity axiom .

Relationship with other edit distance metrics

There are other popular measures of edit distance, which are calculated using a different set of allowable edit operations. For instance,

Edit distance is usually defined as a parameterizable metric calculated with a specific set of allowed edit operations, and each operation is assigned a cost (possibly infinite). This is further generalized by DNA sequence alignment algorithms such as the Smith–Waterman algorithm, which make an operation's cost depend on where it is applied.

See also

Footnotes

  1. ^ "Jaro-Winkler «  Inviting Epiphany". RichardMinerich.com. Retrieved 12 June 2017.

References