Compare 5000 strings with PHP Levenshtein

前端 未结 8 1817
长情又很酷
长情又很酷 2021-01-30 12:15

I have 5000, sometimes more, street address strings in an array. I\'d like to compare them all with levenshtein to find similar matches. How can I do this without looping throug

8条回答
  •  南笙
    南笙 (楼主)
    2021-01-30 12:35

    Due to the nature of the Levenshtein algorithm (specifically the fact that it's a comparision between two strings), I can't see how this is possible.

    You could of course reduce the number of comparisons by performing some basic matching requirements first, but this is out of the scope of what you're asking.

    As a (quite possibly irrelevant) option, you could always use something like soundex which would let you pre-compute the string values. (You can also use it directly in MySQL I believe.)

提交回复
热议问题