in reply to Fast string similarity method

icanwin,
I have not read your implementation at all. If you can use another module to calculate similarity, Text::Levenshtein has a 'fastdistance' method (pure perl) and there is also Text::LevenshteinXS which uses C for speed.

Update: As for your implementation, if you need to compare every string against every other string - the best you can hope for is N * N / 2 comparisons. On the other hand, you may be able to reduce this depending on your requirements.

For instance, if you are interested in strings with an edit distance of less than 5, there is no need to compare strings who have a length difference of 5 or greater. To know the best way to reduce your comparisons, we will need to know more information about your input data and desired output (requirements).

Cheers - L~R

Replies are listed 'Best First'.
Re^2: Fast string similarity method
by icanwin (Acolyte) on May 29, 2007 at 16:53 UTC

    I already check for the string length in order to reduce the comparisions. I didn't post the code due to make it as short as possible.

    I'm currently testing the Text::LevenshteinXS method. It is extremly fast in comparision with the String::Similarity, but I still have to make some changes in order to get the same results.

    UPDATE

    I've made a mistake testing the Text::LevenshteinXSL. Here I post the real time each method took using a 5000 string collection

    Text::LevenshteinXS -> 2m 40s String::Similarity -> 3m
      icanwin,
      I am glad Text::LevenshteinXS looks promising. You have missed my other point though.

      You have asked for helping optimizing your solution but have not provided enough information to do so. There are plenty of "what if" scenarios but you are holding all the cards. If you want more advice beyond faster edit distance checking, please provide more information.

      Cheers - L~R