// echo count($bing_agg); // echo "<br>"; /* Associative Array $blekko contains Url and Score as key => value */ while ($row3 = mysql_fetch_assoc($result_blekko)) { $url3 = $row3['Url']; $score3 = $row3['Score']; $blekko_agg[$url3] = $score3; } // echo "number in Blekko agg: "; // // echo count($blekko_agg); // echo "<br>"; /* aggregate bing and yahoo into a new array called $temp */ $temp_agg = Borda($blekko_agg, $yahoo_agg); /* aggregate $temp and blekko into a new array called $temp2 to give * an aggregates array for all 3 search engines */ $temp2_agg = Borda($bing_agg, $temp_agg); /* Sort new array by descending values */ arsort($temp2_agg); /* "pop" last element from array $temp2 as last element is always " " => NULL * due to final iteration stopping at end */ $end_element = array_pop($temp2_agg); // var_dump($temp2); // used for testing // echo "temp2_agg: "; // echo count($temp2_agg); // echo "<br>"; $aggregated = array(); foreach ($temp2_agg as $url4 => $score3) { $aggregated[] = $url4; } // print_r($aggregated); // echo "<br>";
while ($row2 = mysql_fetch_assoc($result_bing)) { $url2 = $row2['Url']; $score2 = $row2['Score']; $bing[$url2] = $score2; } /* Associative Array $blekko contains Url and Score as key => value */ while ($row3 = mysql_fetch_assoc($result_blekko)) { $url3 = $row3['Url']; $score3 = $row3['Score']; $blekko[$url3] = $score3; } /* aggregate bing and yahoo into a new array called $temp */ $temp = Borda($bing, $yahoo); /* aggregate $temp and blekko into a new array called $temp2 to give * an aggregates array for all 3 search engines */ $temp2 = Borda($blekko, $temp); /* Sort new array by descending values */ arsort($temp2); /* "pop" last element from array $temp2 as last element is always " " => NULL * due to final iteration stopping at end */ $end_element = array_pop($temp2); // var_dump($temp2); // used for testing /* Select all tables from database by the key $url4 and assign it to variable * $test, then echo out results in format below in loop until end of array $temp2 is * reached. A 'union' of all tables must be choosen as union joins all tables into * one but removes any duplicates otherwise if a url in the array $temp2 is in all tables it * will print it to screen 3 times and mess up the ranks as given by iterator $t */ $t = 0; foreach ($temp2 as $url4 => $score3) { $t++; $test = "{$url4}";
function RecalcCentroid($clust) { $num_members = count($clust['members']); $buffer_arr = $clust['members']; $m = 0; $temp = array(); /******** each $buffer_arr only has one element => url => values ********/ for ($m = 0; $m < $num_members; $m++) { foreach ($buffer_arr[$m] as $url) { $temp[$m] = $url; } } $t = 0; $temp2 = array(); $temp2[0] = $temp[0]; // need to call Borda to add values when words match. for ($t = 0; $t < $num_members - 1; $t++) { $temp2[$t + 1] = Borda($temp2[$t], $temp[$t + 1]); // add values together } arsort($temp2[$num_members - 1]); // sort array array_pop($temp2[$num_members - 1]); // 'pop' last NULL element $tempor = array(); // new array to be returned foreach ($temp2[$num_members - 1] as $key => $value) { $tempor[$key] = $value / $num_members; // mean values } /* returns an array with string => value, representing new centroid(a feature vector) */ return $tempor; }