
Perhaps something like this would be better suited for BOOST: http://code.google.com/p/patl/ remi.chateauneu@gmx.de wrote:
Hi,
Is there any interest for a class for computing Levenshtein and Damerau distances ? It is inspired from http://en.wikipedia.org/wiki/Levenshtein_distance with some enhancements:
- The buffer can be reused thanks to a class, avoiding reallocations. - Only one buffer of twice the size of the longest string is necessary (Instead of the product of the size of the two input sequences). (Three times the size for Damerau distance). - It works with any input iterator category for one string, any iterator except input_iterator for the second string. - The distance type is templatized (Allowing to use short ints to save buffer space). - Any type of element can be used (Not only chars). - More efficient than the other implementations I could find on the web, completely inlined (Specific care to maximize memory locality). - The cost function can be specified with a functor (Insertion, deletion, replacement, transposition). - Tested with GCC 3.2.3 and 4.2.3, Visual C++ 2005.
There was a proposal for such a function two years ago (edit_distance), but maybe this one, being faster, might be of interest for the string algorithms library ?
The code is not very big so please let me attach it here.
Thanks
------------------------------------------------------------------------
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost