For a purely mathematical discussion, here is a good post. For a specific concrete example, I use the Affine Edit Distance to determine the difference in two strings.
A common edit distance metric is the Levenshtein distance, which calculates the minimum number of character edits (including insertions or deletions) to convert one string into another string.
The Affine distance, in contrast, penalizes differences in adjacent edits with smaller distance counts. Specifically, Affine edit distance counts one edit for the first difference in two comparison strings, but then for subsequent sequential differences it counts as less than one full edit distance count.
For example suppose there are 3 characters appended to the first comparison string, and that it is otherwise identical to the second comparison string. Suppose also that the Affine distance is counting subsequent sequential edits as 0.5 increments instead of 1.
cat
catsup
Using the Levenshtein edit distance formula, we would calculate an edit distance of 3
between cat
and catsup
, summing 1 for each of s
, u
, and p
.
Using Affine edit distance formula, we would calculate an edit distance of 2
between cat
and catsup
, summing 1 for the first change s
, and 0.5 for u
, and p
.