예제 #1
0
function stringify($data)
{
    if (is_scalar($data) || $data === null) {
        return (string) $data;
    }
    if (is_array($data)) {
        foreach ($data as $key => $val) {
            $data[$key] = stringify($val);
        }
    }
    if (is_object($data)) {
        foreach ($data as $prop => $val) {
            $data->{$prop} = stringify($val);
        }
    }
    return $data;
}
예제 #2
0
            $nextCluster[$nclusterCount]['Musical_Rate'] = floor(20 * $row['AVG_of_Musical_Rate']);
            $nextCluster[$nclusterCount]['Mystery_Rate'] = floor(20 * $row['AVG_of_Mystery_Rate']);
            $nextCluster[$nclusterCount]['Romance_Rate'] = floor(20 * $row['AVG_of_Romance_Rate']);
            $nextCluster[$nclusterCount]['SciFi_Rate'] = floor(20 * $row['AVG_of_SciFi_Rate']);
            $nextCluster[$nclusterCount]['Thriller_Rate'] = floor(20 * $row['AVG_of_Thriller_Rate']);
            $nextCluster[$nclusterCount]['War_Rate'] = floor(20 * $row['AVG_of_War_Rate']);
            $nextCluster[$nclusterCount]['Western_Rate'] = floor(20 * $row['AVG_of_Western_Rate']);
            $clusterLabels = $clusterLabels . "|" . "Segment " . $nextCluster[$nclusterCount]['SegmentID'];
            $clusterQuoteData = $clusterQuoteData . "|" . $nextCluster[$nclusterCount]['Action_Quote'] . "," . $nextCluster[$nclusterCount]['Adventure_Quote'] . "," . $nextCluster[$nclusterCount]['Animation_Quote'] . "," . $nextCluster[$nclusterCount]['Children_Quote'] . "," . $nextCluster[$nclusterCount]['Comedy_Quote'] . "," . $nextCluster[$nclusterCount]['Crime_Quote'] . "," . $nextCluster[$nclusterCount]['Documentary_Quote'] . "," . $nextCluster[$nclusterCount]['Drama_Quote'] . "," . $nextCluster[$nclusterCount]['Fantasy_Quote'] . "," . $nextCluster[$nclusterCount]['FilmNoir_Quote'] . "," . $nextCluster[$nclusterCount]['Horror_Quote'] . "," . $nextCluster[$nclusterCount]['Musical_Quote'] . "," . $nextCluster[$nclusterCount]['Mystery_Quote'] . "," . $nextCluster[$nclusterCount]['Romance_Quote'] . "," . $nextCluster[$nclusterCount]['SciFi_Quote'] . "," . $nextCluster[$nclusterCount]['Thriller_Quote'] . "," . $nextCluster[$nclusterCount]['War_Quote'] . "," . $nextCluster[$nclusterCount]['Western_Quote'];
            $clusterRateData = $clusterRateData . "|" . $nextCluster[$nclusterCount]['Action_Rate'] . "," . $nextCluster[$nclusterCount]['Adventure_Rate'] . "," . $nextCluster[$nclusterCount]['Animation_Rate'] . "," . $nextCluster[$nclusterCount]['Children_Rate'] . "," . $nextCluster[$nclusterCount]['Comedy_Rate'] . "," . $nextCluster[$nclusterCount]['Crime_Rate'] . "," . $nextCluster[$nclusterCount]['Documentary_Rate'] . "," . $nextCluster[$nclusterCount]['Drama_Rate'] . "," . $nextCluster[$nclusterCount]['Fantasy_Rate'] . "," . $nextCluster[$nclusterCount]['FilmNoir_Rate'] . "," . $nextCluster[$nclusterCount]['Horror_Rate'] . "," . $nextCluster[$nclusterCount]['Musical_Rate'] . "," . $nextCluster[$nclusterCount]['Mystery_Rate'] . "," . $nextCluster[$nclusterCount]['Romance_Rate'] . "," . $nextCluster[$nclusterCount]['SciFi_Rate'] . "," . $nextCluster[$nclusterCount]['Thriller_Rate'] . "," . $nextCluster[$nclusterCount]['War_Rate'] . "," . $nextCluster[$nclusterCount]['Western_Rate'];
            $nclusterCount++;
        }
        $quoteChart = "http://chart.googleapis.com/chart?chxl=0:|Action|Adventure|Animation|Children|Comedy|Crime|Documentary|Drama|Fantasy|FilmNoir|Horror|Musical|Mystery|Romance|SciFi|Thriller|War|Western&chxs=0,676767,11.5,1,lt,000000&chxt=x&chs=650x450&cht=r&chco=FF0000,FF9900,3366CC,008000,49188F&chg=5,5,2,2&chls=4|2|2|2|2&chma=|0,5&chtt=Customer Profile&chts=676767,20&chd=t:" . $clusterQuoteData . "&chdl=" . $clusterLabels;
        $rateChart = "http://chart.googleapis.com/chart?chxl=0:|Action|Adventure|Animation|Children|Comedy|Crime|Documentary|Drama|Fantasy|FilmNoir|Horror|Musical|Mystery|Romance|SciFi|Thriller|War|Western&chxs=0,676767,11.5,1,lt,000000&chxt=x&chs=650x450&cht=r&chco=FF0000,FF9900,3366CC,008000,49188F&chg=5,5,2,2&chls=4|2|2|2|2&chma=|0,5&chtt=Rating Profile&chts=676767,20&chd=t:" . $clusterRateData . "&chdl=" . $clusterLabels;
        $Response = array("recoQuery" => $recoQuery, "Settings" => $settings, "Recommendations" => $recommendedList, "QuoteChart" => $quoteChart, "RateChart" => $rateChart, "RatedMovies" => $userHistory);
        echo stringify($Response, $settings["format"]);
        flush();
        break;
}
function getSimilarOffers($offerID, $connection, $limit = 5)
{
    $similarOffers = array();
    $movieResult = $connection->query("SELECT b.*,a.* FROM `offer_association` a, offer_detail b WHERE a.src = '" . $offerID . "' and a.dst = b.offerId GROUP BY a.dst ORDER BY CONF desc LIMIT " . $limit);
    $offerCount = 0;
    while ($row = $movieResult->fetch_assoc()) {
        $similarOffers[$offerCount]['id'] = intval($row["OfferID"]);
        $similarOffers[$offerCount]['title'] = utf8_encode($row["Title"]);
        //$similarOffers[$offerCount]['rating'] = ($row["Rating"]);
        //$similarOffers[$offerCount]['genre'] = utf8_encode($row["Genre"]);
        //$similarOffers[$offerCount]['releaseDate'] = ($row["Released"]);
        //$similarOffers[$offerCount]['director'] = utf8_encode($row["Director"]);
예제 #3
0
            $nextCluster[$nclusterCount]['Mystery_Rate'] = floor(20 * $row['AVG_of_Mystery_Rate']);
            $nextCluster[$nclusterCount]['Romance_Rate'] = floor(20 * $row['AVG_of_Romance_Rate']);
            $nextCluster[$nclusterCount]['SciFi_Rate'] = floor(20 * $row['AVG_of_SciFi_Rate']);
            $nextCluster[$nclusterCount]['Thriller_Rate'] = floor(20 * $row['AVG_of_Thriller_Rate']);
            $nextCluster[$nclusterCount]['War_Rate'] = floor(20 * $row['AVG_of_War_Rate']);
            $nextCluster[$nclusterCount]['Western_Rate'] = floor(20 * $row['AVG_of_Western_Rate']);
            $clusterLabels = $clusterLabels . "|" . "Segment " . $nextCluster[$nclusterCount]['SegmentID'];
            $clusterQuoteData = $clusterQuoteData . "|" . $nextCluster[$nclusterCount]['Action_Quote'] . "," . $nextCluster[$nclusterCount]['Adventure_Quote'] . "," . $nextCluster[$nclusterCount]['Animation_Quote'] . "," . $nextCluster[$nclusterCount]['Children_Quote'] . "," . $nextCluster[$nclusterCount]['Comedy_Quote'] . "," . $nextCluster[$nclusterCount]['Crime_Quote'] . "," . $nextCluster[$nclusterCount]['Documentary_Quote'] . "," . $nextCluster[$nclusterCount]['Drama_Quote'] . "," . $nextCluster[$nclusterCount]['Fantasy_Quote'] . "," . $nextCluster[$nclusterCount]['FilmNoir_Quote'] . "," . $nextCluster[$nclusterCount]['Horror_Quote'] . "," . $nextCluster[$nclusterCount]['Musical_Quote'] . "," . $nextCluster[$nclusterCount]['Mystery_Quote'] . "," . $nextCluster[$nclusterCount]['Romance_Quote'] . "," . $nextCluster[$nclusterCount]['SciFi_Quote'] . "," . $nextCluster[$nclusterCount]['Thriller_Quote'] . "," . $nextCluster[$nclusterCount]['War_Quote'] . "," . $nextCluster[$nclusterCount]['Western_Quote'];
            $clusterRateData = $clusterRateData . "|" . $nextCluster[$nclusterCount]['Action_Rate'] . "," . $nextCluster[$nclusterCount]['Adventure_Rate'] . "," . $nextCluster[$nclusterCount]['Animation_Rate'] . "," . $nextCluster[$nclusterCount]['Children_Rate'] . "," . $nextCluster[$nclusterCount]['Comedy_Rate'] . "," . $nextCluster[$nclusterCount]['Crime_Rate'] . "," . $nextCluster[$nclusterCount]['Documentary_Rate'] . "," . $nextCluster[$nclusterCount]['Drama_Rate'] . "," . $nextCluster[$nclusterCount]['Fantasy_Rate'] . "," . $nextCluster[$nclusterCount]['FilmNoir_Rate'] . "," . $nextCluster[$nclusterCount]['Horror_Rate'] . "," . $nextCluster[$nclusterCount]['Musical_Rate'] . "," . $nextCluster[$nclusterCount]['Mystery_Rate'] . "," . $nextCluster[$nclusterCount]['Romance_Rate'] . "," . $nextCluster[$nclusterCount]['SciFi_Rate'] . "," . $nextCluster[$nclusterCount]['Thriller_Rate'] . "," . $nextCluster[$nclusterCount]['War_Rate'] . "," . $nextCluster[$nclusterCount]['Western_Rate'];
            $nclusterCount++;
        }
        $quoteChart = "http://chart.googleapis.com/chart?chxl=0:|Action|Adventure|Animation|Children|Comedy|Crime|Documentary|Drama|Fantasy|FilmNoir|Horror|Musical|Mystery|Romance|SciFi|Thriller|War|Western&chxs=0,676767,11.5,1,lt,000000&chxt=x&chs=650x450&cht=r&chco=FF0000,FF9900,3366CC,008000,49188F&chg=5,5,2,2&chls=4|2|2|2|2&chma=|0,5&chtt=Customer Profile&chts=676767,20&chd=t:" . $clusterQuoteData . "&chdl=" . $clusterLabels;
        $rateChart = "http://chart.googleapis.com/chart?chxl=0:|Action|Adventure|Animation|Children|Comedy|Crime|Documentary|Drama|Fantasy|FilmNoir|Horror|Musical|Mystery|Romance|SciFi|Thriller|War|Western&chxs=0,676767,11.5,1,lt,000000&chxt=x&chs=650x450&cht=r&chco=FF0000,FF9900,3366CC,008000,49188F&chg=5,5,2,2&chls=4|2|2|2|2&chma=|0,5&chtt=Rating Profile&chts=676767,20&chd=t:" . $clusterRateData . "&chdl=" . $clusterLabels;
        $DebugInfo = array("USER_ID" => $_SESSION['userid'], "N_CLUSTERS" => $_SESSION['nclusters'], "N_MOVIES" => $_SESSION['nmovies']);
        $Response = array("Recommendations" => $recommendedList, "NNClusters" => $nextCluster, "QuoteChart" => $quoteChart, "RateChart" => $rateChart, "RatedMovies" => $historyList, "DebugInfo" => $DebugInfo);
        echo stringify($Response);
        break;
}
function stringify($response)
{
    if ($_SESSION["format"] == "xml") {
        @header('Content-type: application/xml');
        return XMLSerializer::generateValidXmlFromArray($response);
    } else {
        @header('Content-type: application/json');
        return indent(json_encode($response));
    }
}
/**
 * Indents a flat JSON string to make it more human-readable.
 *
예제 #4
0
파일: spam.php 프로젝트: TamirAl/hubzilla
function get_words($uid, $list)
{
    stringify($list, true);
    $r = q("select * from spam where term in ( " . $list . ") and uid = %d", intval($uid));
    return $r;
}
예제 #5
0
 /**
  * @param mixed $ids
  * @param bool $null
  * @return $this
  */
 public function processID(&$ids, $null = false)
 {
     $filter = $null ? '_idNull' : '_id';
     if (is_array($ids)) {
         $returnArray = true;
     } else {
         $returnArray = false;
         $ids = array($ids);
     }
     foreach ($ids as $i => &$id) {
         if (!call_user_func_array(array($this, $filter), array(&$id))) {
             unset($ids[$i]);
         }
     }
     if (empty($ids)) {
         return $this->addError('validation', 5, array(stringify($ids)));
     }
     return $this->result($ids = $returnArray ? $ids : $ids[0]);
 }
예제 #6
0
파일: index.php 프로젝트: nevali/canonical
	public function sortTriples($triples, $dedupe = false)
	{
		$this->triples = array();
		$c = 0;
		foreach($triples as $triple)
		{
			$k = '<' . $triple->predicate . '> ' . stringify($triple->object);
			if(!$dedupe)
			{
				$k .= sprintf('%04d', $c);
			}
			$c++;			
			$this->triples[$k] = $triple;
		}
	}
예제 #7
0
파일: sxsw-lastfm.php 프로젝트: hubgit/sxsw
<?php

require 'config.inc.php';
$in = fopen('sxsw.csv', 'r');
$out = fopen('sxsw-lastfm.csv', 'w');
while ($data = fgetcsv($in, 0, "\t", '"')) {
    list($artist, $url) = $data;
    $params = array('api_key' => $config['lastfm-api-key'], 'method' => 'artist.getinfo', 'artist' => $artist);
    $url = 'http://ws.audioscrobbler.com/2.0/?' . http_build_query($params);
    $xml = simplexml_load_string(get($url));
    $xml = $xml->artist[0];
    $data = array('name' => (string) $xml->name, 'mbid' => (string) $xml->mbid, 'listeners' => (int) $xml->stats->listeners, 'playcount' => (int) $xml->stats->playcount, 'url' => (string) $xml->url, 'image' => (string) $xml->image[2], 'streamable' => (int) $xml->streamable, 'similar' => implode('|', stringify($xml->similar->artist, 'name')));
    fputcsv($out, $data, "\t", '"');
}
fclose($in);
fclose($out);
function stringify($xml, $node)
{
    if (empty($xml)) {
        return array();
    }
    $items = array();
    foreach ($xml as $item) {
        $items[] = (string) $item->{$node};
    }
    print_r($items);
    return $items;
}
function get($url)
{
    print $url . "\n";
예제 #8
0
    if (0 == strcasecmp($phase, "test build")) {
        $idx = process_phase($phase_name);
    } else {
        if (0 == strcasecmp($phase, "mpi install")) {
            $idx = process_phase($phase_name);
        } else {
            print "ERROR: Unknown phase! ({$phase})<br>\n";
            mtt_abort(400, "\nNo phase given, so I don't know which table to direct this data to.");
            exit(1);
        }
    }
}
#
# Return necessary indexes to the MTT client
#############################################
print "\n{$marker} {$phase_name}{$id}" . " = " . stringify($idx) . " {$marker}\n";
# All done
pg_close();
exit(0);
######################################################################
function process_phase($phase)
{
    global $id;
    $results_idxs_hash = array();
    ########
    # Select/Insert: submit_id
    #
    # It is impossible to submit with two different submit identities
    # so grab the one and only submit_id
    # IF DISCONNECTED SCENARIOS COMES TO PASS, THIS WILL NEED
    # TO BE CHANGED