Skip to content

Instantly share code, notes, and snippets.

@Ryokuchaneko
Last active December 19, 2015 16:29
Show Gist options
  • Save Ryokuchaneko/5983812 to your computer and use it in GitHub Desktop.
Save Ryokuchaneko/5983812 to your computer and use it in GitHub Desktop.
今まで用いてきた評価者ごとの映画の評価配列を映画ごとの評価配列に変換する 以前に定義したtopMatches関数を使って、似た属性をもつ映画をランキング形式で表示できる。また、映画が誰に見られるべきかをgetRecommendationsを使って表示することができる
function transformPrefs($critics) {
$result = array();
foreach ($critics as $key => $person) {
foreach ($person as $item => $value) {
if(!isset($result[$item])){
$resutl[$item] = array();
}
$result[$item][$key] = $value;
}
}
return $result;
}
$movies = transformPrefs($critics);
$result = topMatches($movies, 'Superman Returns', 4, 'pearson');
var_dump($result);
$recomend_person = getRecommendations($movies, 'Just My Luck', 'pearson');
var_dump($recomend_person);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment