# Cross between an edit distance algorithm and a phonetic algorithm

My aim is to find an edit distance algorithm which penalises transformations differently depending on the phonetic context.

Take the Levenshtein algorithm, for example; it penalises the same operation - like a character substitution - equally, regardless of character context.

However, it seems to me that all substitutions/insertions/deletions are not made equal. For example, in some contexts, the transformation C->K should not be as harshly penalised as A->T.

A phonetic algorithm, like Double Metaphone, can help here. It maps both kosmetik and cosmetic to the same phonetic key, but it's aggressive and discards information. There's a clear difference between these two strings even though the phonetic key is the same.

Simply taking the Metaphone key and applying an edit distance algorithm is a poor choice for my goal.

Does a suitable method exist here? Or is the best option to manually fiddle with the internals of an edit distance algorithm?