function aggregateCombMNZ($googleArray, $bingArray, $blekkoArray)
{
    //get the result set sizes in case a search engine hasn't returned
    //the specified number of results
    $googleResultSetSize = sizeof($googleArray);
    $bingResultSetSize = sizeof($bingArray);
    $blekkoResultSetSize = sizeof($blekkoArray);
    $m = 0;
    for ($i = 0; $i < $googleResultSetSize; $i++) {
        for ($j = 0; $j < $bingResultSetSize; $j++) {
            if (strcmp($googleArray[$i][0], $bingArray[$j][0]) == 0 && $googleArray[$i][4] != 1 && $bingArray[$j][4] != 1) {
                //1. url 2. snippet 3. rank 4. combMNZ 5. aggregated 6. search engine 7. number of engines 8. the cluster number (default zero)
                //our paired url 9. the title
                $combinedTmpArray[$m][0] = $googleArray[$i][0];
                $combinedTmpArray[$m][1] = $googleArray[$i][1];
                //our combined rank - lowest is best
                $combinedTmpArray[$m][2] = convertRankOneToZero($googleArray[$i][2], $googleResultSetSize) + convertRankOneToZero($bingArray[$j][2], $bingResultSetSize);
                //our combMNZ score
                $combinedTmpArray[$m][3] = $combinedTmpArray[$m][2] * 2;
                $combinedTmpArray[$m][4] = 1;
                //make sure these elements aren't counted twice
                $googleArray[$i][4] = 1;
                $bingArray[$j][4] = 1;
                //string identifier for search engines
                $combinedTmpArray[$m][5] = "Google Bing";
                //the number of search engines returning
                $combinedTmpArray[$m][6] = 2;
                //the index of the cluster - this will be filled in in the cluster function
                $combinedTmpArray[$m][7] = 0;
                //an array for the cluster vectors
                $combinedTmpArray[$m][8] = array();
                //a value for snippet magnitude
                $combinedTmpArray[$m][9] = 0;
                //the display title
                $combinedTmpArray[$m][10] = $googleArray[$i][7];
                $m++;
            }
        }
    }
    $j = sizeof($combinedTmpArray);
    for ($i = 0; $i < $googleResultSetSize; $i++) {
        if ($googleArray[$i][4] == 0) {
            $combinedTmpArray[$j][0] = $googleArray[$i][0];
            $combinedTmpArray[$j][1] = $googleArray[$i][1];
            //our combined rank - lowest is best
            $combinedTmpArray[$j][2] = convertRankOneToZero($googleArray[$i][2], $googleResultSetSize);
            //our combMNZ score
            $combinedTmpArray[$j][3] = $combinedTmpArray[$j][2];
            $combinedTmpArray[$j][4] = 1;
            //make sure these elements aren't counted twice
            $googleArray[$i][4] = 1;
            //string identifier for search engines
            $combinedTmpArray[$j][5] = $googleArray[$i][5];
            //the number of search engines returning
            $combinedTmpArray[$j][6] = 1;
            //the index of the cluster - this will be filled in in the cluster function
            $combinedTmpArray[$j][7] = 0;
            //an array for the cluster vectors
            $combinedTmpArray[$j][8] = array();
            $combinedTmpArray[$j][9] = 0;
            //the display title
            $combinedTmpArray[$j][10] = $googleArray[$i][7];
            $j++;
        }
    }
    for ($i = 0; $i < $bingResultSetSize; $i++) {
        if ($bingArray[$i][4] == 0) {
            $combinedTmpArray[$j][0] = $bingArray[$i][0];
            $combinedTmpArray[$j][1] = $bingArray[$i][1];
            //our combined rank - lowest is best
            $combinedTmpArray[$j][2] = convertRankOneToZero($bingArray[$i][2], $bingResultSetSize);
            //our combMNZ score
            $combinedTmpArray[$j][3] = $combinedTmpArray[$j][2];
            $combinedTmpArray[$j][4] = 1;
            //make sure these elements aren't counted twice
            $bingArray[$i][4] = 1;
            //string identifier for search engines
            $combinedTmpArray[$j][5] = $bingArray[$i][5];
            //the number of search engines returning
            $combinedTmpArray[$j][6] = 1;
            //the index of the cluster - this will be filled in in the cluster function
            $combinedTmpArray[$j][7] = 0;
            //an array for the cluster vectors
            $combinedTmpArray[$j][8] = array();
            $combinedTmpArray[$j][9] = 0;
            //the display title
            $combinedTmpArray[$j][10] = $bingArray[$i][7];
            $j++;
        }
    }
    for ($i = 0; $i < $j; $i++) {
        for ($m = 0; $m < $blekkoResultSetSize; $m++) {
            if (strcmp($combinedTmpArray[$i][0], $blekkoArray[$m][0]) == 0 && $blekkoArray[$m][4] != 1) {
                //our combined rank - lowest is best
                $combinedTmpArray[$i][2] += convertRankOneToZero($blekkoArray[$m][2], $blekkoResultSetSize);
                //our combMNZ score
                if ($combinedTmpArray[$i][6] == 1) {
                    $combinedTmpArray[$i][3] = $combinedTmpArray[$i][2] * 2.0;
                } else {
                    $combinedTmpArray[$i][3] = $combinedTmpArray[$i][2] * 3.0;
                }
                $combinedTmpArray[$i][4] = 1;
                //make sure these elements aren't counted twice
                $blekkoArray[$m][4] = 1;
                //string identifier for search engines
                $combinedTmpArray[$i][5] .= " Blekko";
                //the number of search engines returning
                $combinedTmpArray[$i][6] += 1;
                //the index of the cluster - this will be filled in in the cluster function
                $combinedTmpArray[$i][7] = 0;
                //an array for the cluster vectors
                $combinedTmpArray[$i][8] = array();
                //the display title
                $combinedTmpArray[$i][9] = 0;
            }
        }
    }
    for ($i = 0; $i < $blekkoResultSetSize; $i++) {
        if ($blekkoArray[$i][4] == 0) {
            $combinedTmpArray[$j][0] = $blekkoArray[$i][0];
            $combinedTmpArray[$j][1] = $blekkoArray[$i][1];
            //our combined rank - lowest is best
            $combinedTmpArray[$j][2] = convertRankOneToZero($blekkoArray[$i][2], $blekkoResultSetSize);
            //our combMNZ score
            $combinedTmpArray[$j][3] = $combinedTmpArray[$j][2];
            $combinedTmpArray[$j][4] = 1;
            //make sure these elements aren't counted twice
            $blekkoArray[$i][4] = 1;
            //string identifier for search engines
            $combinedTmpArray[$j][5] = $blekkoArray[$i][5];
            //string identifier for search engines
            $combinedTmpArray[$j][6] = 1;
            //the index of the cluster - this will be filled in in the cluster function
            $combinedTmpArray[$j][7] = 0;
            //an array for the cluster vectors
            $combinedTmpArray[$j][8] = array();
            $combinedTmpArray[$j][9] = 0;
            //the display title
            $combinedTmpArray[$j][10] = $blekkoArray[$i][7];
            $j++;
        }
    }
    //the last step is to order the array which we will do by the 3rd index of the array i.e. the CombMNZ value
    arraySortByColumn($combinedTmpArray, 3, SORT_DESC);
    return $combinedTmpArray;
}
Example #2
0
	 <div class="span4" id="divCheckboxBlekko" style="display: none;"></div>
        <div class="span4" id="divCheckboxGoogle" style="display: none;"></div>', $finalResultStr, $contents);
}
//display our clustered results
if ($outputType == 3) {
    $combinedArray = aggregateCombMNZ($googleResultArray, $bingResultArray, $blekkoResultArray);
    $clusteredArray = $combinedArray;
    //we will need to look into the object array in order to do the cluster mappings
    cluster($clusteredArray, 4);
    //copy the original snippets back into the clustered array
    $arrSize = sizeof($clusteredArray);
    for ($i = 0; $i < $arrSize; $i++) {
        $clusteredArray[$i][1] = $combinedArray[$i][1];
    }
    //sort array by cluster index
    arraySortByColumn($clusteredArray, 7, SORT_ASC);
    $finalResultStr .= '<div class="span12">';
    $check == 0;
    for ($i = 0; $i < $arrSize; $i++) {
        //1. url 2. snippet 3. rank 4. combMNZ 5. aggregated 6. search engine 7. number of engines
        //this splits off the clusters into differently coloured columns
        if ($clusteredArray[$i][7] == 1 && $check == 0) {
            $finalResultStr .= '<div class="span3" style="padding:3px 3px">';
            $check = 1;
        }
        if ($clusteredArray[$i][7] == 2 && $check == 1) {
            $finalResultStr .= '</div>';
            $finalResultStr .= '<div class="span3" style="padding:3px 3px">';
            $check = 2;
        }
        if ($clusteredArray[$i][7] == 3 && $check == 2) {