Compare 5000 strings with PHP Levenshtein

前端 未结 8 1769
长情又很酷
长情又很酷 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:31

    You could group them based on soundexes then limit the comparisons to the nearest N cases...

     $mashed=array();
     foreach ($address as $key=>$val) {
          $mashed[$key]=soundex($val);
     }
     sort($mashed);
    

    Then iterate through the keys of $mashed.

    C.

提交回复
热议问题