|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I understand its possible to locate substrings within a string (http://
http://www.cplusplus.com/reference/s...ring/find.html) but is it possible to compare two strings for a particular threshold of similarity. Like saying return true if string1 and string2 are say, 80% alike? |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Travis schrieb:
> I understand its possible to locate substrings within a string (http:// > http://www.cplusplus.com/reference/s...ring/find.html) but is it > possible to compare two strings for a particular threshold of > similarity. Like saying return true if string1 and string2 are say, > 80% alike? > I don't think STL can do this, but there are many libraries with such algorithms. Best regards |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Feb 22, 2:00 pm, Hans Mull <hans72m...@aol.de> wrote:
> Travis schrieb:> I understand its possible to locate substrings within a string (http:// > >http://www.cplusplus.com/reference/s...ring/find.html) but is it > > possible to compare two strings for a particular threshold of > > similarity. Like saying return true if string1 and string2 are say, > > 80% alike? > > I don't think STL can do this, but there are many libraries with such > algorithms. > > Best regards I figured there might be I was just trying to get some recommendations. I know I have boost installed but can't seem to find the functions to fit. Thanks for the info. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Travis wrote:
> is it possible to compare two strings for a particular threshold of > similarity. Like saying return true if string1 and string2 are say, > 80% alike? Of course it's *possible*. However, if what you wanted to ask is whether there exists a standard library function to do that, then the answer is no. If you want such a function you'll have to write it yourself (or find a third-party library which has such a function). |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Feb 22, 4:44pm, Travis <travis.bow...@gmail.com> wrote:
> I understand its possible to locate substrings within a string (http://www..cplusplus.com/reference/...ring/find.html) but is it > possible to compare two strings for a particular threshold of > similarity. Like saying return true if string1 and string2 are say, > 80% alike? Check out the definition of Levenshtein distance: http://en.wikipedia.org/wiki/Levenshtein_distance The article has many good pointers to other definitons of distance or likeness. You can find an implementation on google by searching for the above along with the term C++. HTH |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
Travis wrote:
> I understand its possible to locate substrings within a string (http:// > http://www.cplusplus.com/reference/s...ring/find.html) but is it > possible to compare two strings for a particular threshold of > similarity. Like saying return true if string1 and string2 are say, > 80% alike? Maybe "edit distance" is the thing you need to search for? My own (GPL) implementation is here: https://svn.chezphil.org/anyterm/trunk/common/diff.cc If you search for "edit distance" in the Boost mailing list archive I think you'll find at least one implementation proposed. (IIRC, I complained that it was not optimal; the author them presented a much better version.) Phil. |
|
![]() |
| Outils de la discussion | |
|
|