That sample code had no other purpose than illustrate my problem. But what I really want is to perform a statistical comparison of each string in a list with all others in the same list, using one of the indexes provided in the FuzzyWuzzy library (https://github.com/DavidMoraisFerreira/FuzzyWuzzy.pas (https://github.com/DavidMoraisFerreira/FuzzyWuzzy.pas)).Uh, you do realize, that's not what you're doing with your simple loop?
you do realize (i admit, haven't looked too closely) that you compare strings twice?
Continuous memory leak? :o
If you don't need the ratio and all the other stuff implemented and are just looking for the Levenshtein Distance, the Free Pascal wiki has an article with code to implement it:
https://wiki.freepascal.org/Levenshtein_distance
Quote from: Gustavo 'Gus' Carreno on: Today at 04:31:14 pmIf you don't need the ratio and all the other stuff implemented and are just looking for the Levenshtein Distance, the Free Pascal wiki has an article with code to implement it:
https://wiki.freepascal.org/Levenshtein_distance
To be honest, I think this is the worst example of the Levenshtein distance function.
Is the implementation on the FuzzyWuzzy.pas/Levenshtein.pas repo better?
In this case, is there an alternative?
Hey Zvoni,Permutation = Respect the order of draw with/without repeatyou do realize (i admit, haven't looked too closely) that you compare strings twice?
Yeap, you are completely right!
I opted for the lazy, brute force approach of just doing it with a simple 2 nested loops and skipping comparing the same indexes.
There is of course a more complex way of doing it that will not make reverse comparisons.
I guess it's the permutations versus (Crap, I always forget the other name, the one with repeats, or is permutations the one with repeats? ARGHHH brain is not working ATM, sorry!!!) dilemma.
I'll let the more complex routine with no repeats as an exercise to the person that has the brain more switched on than I do :)
Cheers,
Gus
Quote from: Gustavo 'Gus' Carreno on: Today at 05:03:11 pmIs the implementation on the FuzzyWuzzy.pas/Levenshtein.pas repo better?
The implementation you mentioned calls as the Levenshtein distance a slightly different distance function.
Quote from: maurobio on: Today at 04:19:49 pmIn this case, is there an alternative?
I tried to implement some string algorithms, for example, here (https://github.com/avk959/LGenerics/blob/3b3340008f6affd03611869e0c1f175389b9a78d/lgenerics/lgstrhelpers.pas#L330), but not all are implemented for unicode strings :(.
Permutation = Respect the order of draw with/without repeat
Combination = No respect for order of draw with/without repeat
Gus, it‘s the reason why i wrote to remove current member of list1 from list2
Basically, it boils down to combination without repeat, which btw is a Lottery („6 out of 49“ etc.)
Would it be too much of an effort to make them UTF8 compatible...
Of course not, I just don't have a dozen hands and heads.
IIRC, the Ratio() and PartialRatio() functions do without leaks, but do they seem the most interesting?