I'm trying to calculate the Levenshtein distance (with weight) between two lists of numbers.
import textdistance
S1 = [1, 2, 3, 7, 9, 15, 19, 20]
S2 = [1, 2, 3, 7, 98, 99, 20]
textdistance.levenshtein.similarity(S1, S2)
textdistance.levenshtein.distance(S1, S2)
Except here every operation has a cost of 1, and I'd like to define different cost values when replacing/removing certain digits, for example, 1 - 20
all have a cost of 1
, but 98
has a cost of 10
and 99
has a cost of 15
etc. I did some searches and found this library, however, it works with string, and converting ints to string doesn't work, since it iterates char by char, and 9 can't be compared to 98 anymore for example.
Is there any workaround or existing library that does this, or perhaps can achieve the same result, or do I need to implement it from scratch?