Almost there. This look right to you?
This is what I got for code to do dot product calculation in php. ChatGPT3 was the only place I could find it:
function dotProduct($a, $b) {
$result = 0;
for ($i = 0; $i < count($a); $i++) {
$result += $a[$i] * $b[$i];
}
return $result;
}
Results:
php dot_product.php cat sushi
Results 0.77132901214151php dot_product.php happy glad
Results 0.87059063038805php dot_product.php paris france
Results 0.89271812225079php dot_product.php cat kitten
Results 0.85994720919874php dot_product.php dog cat
Results 0.86354635106737php dot_product.php cat dog
Results 0.86384264229314php dot_product.php cat kitten
Results 0.85994720919874php dot_product.php dog puppy
Results 0.87417191528759
Unable to find anything I can understand on Google to compare with (specific to php).
Thanks!