1

私が2つの文を持っているとしましょう:

「速い茶色のキツネが怠惰な犬を飛び越える」

「速い茶色のバニーが怠惰な猫を飛び越える」

これら2つの文の類似度を検出するアルゴリズムはありますか?例えば:

function similarity_ratio($text1, $text2) {
code code code
return $similarity_ratio;
}
$text1 = "The quick brown fox jumps over the lazy dog";
$text2 = "The quick brown cat jumps over the lazy chicken";
echo similarity_ratio($text1, $text2);
// output 88%
4

3 に答える 3

6
function similarity_ratio($text1, $text2) {
     similar_text($text1, $text2, $similarity_ratio);
     return $similarity_ratio;
}

$text1 = "The quick brown fox jumps over the lazy dog";
$text2 = "The quick brown fox jumps over the lazy cat";
echo similarity_ratio($text1, $text2);

Output: 93.023255813953
于 2012-07-25T09:21:14.467 に答える
4

このPHP関数を見てください:http://php.net/manual/en/function.similar-text.php

于 2012-07-25T09:15:55.123 に答える
2

これをお探しですか?http://php.net/manual/en/function.similar-text.php。速度が重要な場合は、これを考慮してください:http: //php.net/manual/en/function.levenshtein.php

于 2012-07-25T09:16:06.220 に答える