報告站表:
忽然一堆程式碼~_~
';
// $user_query_1 = '提供台北天氣資訊';
// //string matching
// $dist = levenshtein($str1, $str2);
// echo $dist;
// //利用cosine similarity方式進行相似度比較
// //jaccard similarity
// $data1 = explode(" ", $str1);
// $data2 = explode(" ", $str2);
// //
// $intersectionNum = count(array_intersect($data1, $data2));
// $unionNum = count(array_unique(array_merge($data1, $data2)));
// //計算jacard similarity
// $jaccardSimilarityValue = $intersectionNum / $unionNum;
// echo 'jaccardSimilarityValue: '. $jaccardSimilarityValue;
// //generate neural network
// $queryReplies = [
// '今天台北市的天氣為?' => '今天台北市天氣晴朗',
// '請問台北市的氣溫' => '台北市的氣溫約為 29 度',
// '請問台北市的濕度' => '台北市的濕度約為 75%',
// ];
// preg_match_all("/\w+/", implode(' ', array_keys($queryReplies)), $matches);
// $words = array_unique(array_merge(...$matches));
// //
// $queryVector = [];
// foreach ($words as $word) {
// $wordCount = 0;
// foreach ($queryReplies as $query => $reply) {
// $wordCount += substr_count(strtolower($query), $word);
// }
// $queryVector[] = $wordCount;
// }
// echo '
';
// print_r($queryVector);
?>
$str1 ='今天台北天氣';
$str2 = '提供台