String Comparison Threshholds

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Travis

    #1

    String Comparison Threshholds

    I understand its possible to locate substrings within a string (http://
    https://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?

  • Hans Mull

    #2
    Re: String Comparison Threshholds

    Travis schrieb:
    I understand its possible to locate substrings within a string (http://
    https://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?
    >
    I don't think STL can do this, but there are many libraries with such
    algorithms.

    Best regards

    Comment

    • Travis

      #3
      Re: String Comparison Threshholds

      On Feb 22, 2:00 pm, Hans Mull <hans72m...@aol .dewrote:
      Travis schrieb:I understand its possible to locate substrings within a string (http://
      https://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?
      >
      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.

      Comment

      • Juha Nieminen

        #4
        Re: String Comparison Threshholds

        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).

        Comment

        • AnonMail2005@gmail.com

          #5
          Re: String Comparison Threshholds

          On Feb 22, 4:44 pm, Travis <travis.bow...@ gmail.comwrote:
          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:


          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

          Comment

          • Phil Endecott

            #6
            Re: String Comparison Threshholds

            Travis wrote:
            I understand its possible to locate substrings within a string (http://
            https://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?
            Maybe "edit distance" is the thing you need to search for?

            My own (GPL) implementation is here:



            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.

            Comment

            Working...