I wanted to implement a modification of the basic edit distance algorithm. That is, the weighted edit distance. (Context: Spelling errors while trying to create a search engine)
For example, the cost of substituting s by a would be lesser than substituting s by, say, p.
The algorithm for this using DP would require a simple change, i.e.,
d[i, j] := minimum(d[i-1, j] + 1, // deletion
d[i, j-1] + 1, // insertion
d[i-1, j-1] + substitutionCost) // substitution
I looked, but I could not find such a matrix anywhere, that would give me the appropriate substitutionCost for all pairs of letters. I mean, I want the costs to be based on the distance between letters on the keyboard. Has nobody explicitly defined such a matrix yet?