Last active
December 19, 2015 16:29
-
-
Save Ryokuchaneko/5983812 to your computer and use it in GitHub Desktop.
今まで用いてきた評価者ごとの映画の評価配列を映画ごとの評価配列に変換する
以前に定義したtopMatches関数を使って、似た属性をもつ映画をランキング形式で表示できる。また、映画が誰に見られるべきかをgetRecommendationsを使って表示することができる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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