giacomocavalieri / edit_distance

📝 A pure Gleam package to compute the edit distance of two strings
https://hexdocs.pm/edit_distance/
Apache License 2.0
6 stars 1 forks source link

[Feature] Allow computing normalized distances #3

Open NicklasXYZ opened 2 months ago

NicklasXYZ commented 2 months ago

Enable the option to compute the normalized distance, which returns a value between 0 and 1. A result of 0 indicates no similarity between the provided strings, while a result of 1 indicates a perfect match as determined by the similarity function. This feature could be useful when applying a threshold to determine whether two strings are sufficiently similar.

giacomocavalieri commented 2 months ago

How would you compute that?

NicklasXYZ commented 2 months ago

I would simply divide the computed edit distance by the size of the longest string (the upper bound in the edit distance).

giacomocavalieri commented 2 months ago

Mmh, I'm not entirely sure if this should be part of the library itself or could just be implemented by the user if they need it since it looks pretty straightforward

NicklasXYZ commented 2 months ago

Depending on how advanced you want the library to be it could be worth adding. For example, if you're allowed to use non-uniform weights for the edit operations then the (maximum) factor you need to normalize by might not be too straight forward for the users themselves to compute.