infoscout / weighted-levenshtein

Weighted Levenshtein library
MIT License
105 stars 26 forks source link

Cost value can't exceed 2? #30

Open peilinUWU opened 2 years ago

peilinUWU commented 2 years ago

Using the given example:

insert_costs = np.ones(128, dtype=np.float64) 
insert_costs[ord('D')] = 1.5
print(lev('BANANAS', 'BANDANAS', insert_costs=insert_costs))  # prints '1.5'

We get a printout 1.5, no problem. If I change the cost to a higher value, say 5, then it prints 2.0. Am I missing something?

dsu1995 commented 2 years ago

In this paricular case, it would be cheaper to substitute A -> D (cost 1), then insert the A back (cost 1), yielding a lower cost of 2:

peilinUWU commented 2 years ago

Edited: Thanks that makes sense!