D'ish similar_text?
Dgame
r.schuett.1987 at gmail.com
Thu May 10 21:00:21 UTC 2018
On Thursday, 10 May 2018 at 20:38:12 UTC, Vladimir Panteleev
wrote:
> On Thursday, 10 May 2018 at 20:32:11 UTC, Dgame wrote:
>> immutable size_t len = s1.length + s2.length;
>> percent = (len - distance) * 100.0 / len;
>
> Note that this formula will give you only 50% similarity for
> "abc" and "def", i.e. two completely different strings. I
> suggest to divide by max(s1.length, s2.length) instead.
Hm, that does not work either. ABC and AZB have a different
outcome with both. How can I calculate the percentage with
levenshtein? It's rather simple with similar_text since it
returns the amount of similar chars.
More information about the Digitalmars-d-learn
mailing list