wxString Levensthein distance

If you have a cool piece of software to share, but you are not hosting it officially yet, please dump it in here. If you have code snippets that are useful, please donate!
mjx
In need of some credit
In need of some credit
Posts: 2
Joined: Mon Aug 23, 2010 9:53 pm
Location: Krefeld, Germany
Contact:

wxString Levensthein distance

Postby mjx » Fri May 25, 2012 8:40 pm

As this method did not make it into wxWidgets itself ( http://trac.wxwidgets.org/ticket/14321 ), i'll post this little piece of code here, maybe it's useful to someone.

Code: Select all

int LevenshteinDistance(const wxString &s1, const wxString &s2);

The Levenshtein distance between two strings is defined as the minimum number of edits needed to transform one string into the other, with the allowable edit operations being insertion, deletion, or substitution of a single character.

http://en.wikipedia.org/wiki/Levenshtein_distance
Attachments
levenshtein.zip
(701 Bytes) Downloaded 117 times

tuli
Knows some wx things
Knows some wx things
Posts: 42
Joined: Sat Dec 03, 2011 3:56 pm

Re: wxString Levensthein distance

Postby tuli » Sat May 26, 2012 8:23 am

that`d be very nice to have, imo.
maybe consider this:

Perhaps we could add it as an inline global function in its own header (wx/algorithm/levenstein.h?) but I'd really like to avoid adding more methods to wxString itself.


i`d love to see this...thanks for your work!

mjx
In need of some credit
In need of some credit
Posts: 2
Joined: Mon Aug 23, 2010 9:53 pm
Location: Krefeld, Germany
Contact:

Re: wxString Levensthein distance

Postby mjx » Sat May 26, 2012 12:22 pm

Perhaps we could add it as an inline global function in its own header (wx/algorithm/levenstein.h?) but I'd really like to avoid adding more methods to wxString itself.
I personally think if it's in the library, it should be a wxString method, that's where people would look for it. Therefore i decided against doing this.

tuli
Knows some wx things
Knows some wx things
Posts: 42
Joined: Sat Dec 03, 2011 3:56 pm

Re: wxString Levensthein distance

Postby tuli » Sat May 26, 2012 12:52 pm

yeah, but they dont want it there. I have to agree - it`s something you wont use in your average project, or during everyday string-based work.
I also would start looking exactly here: wx/algorithm/levenstein.h, as proposed.

and: in the library as an algorithm is in any case better than not in the library at all, wouldn't you agree? ;)


Return to “The Code Dump”

Who is online

Users browsing this forum: No registered users and 1 guest