public static function calcRecommendations($filename, $limit = false) { $f = fopen($filename, "w"); $stubs = Recommendations::findStubs($limit); $r = new Recommendations(); $r->excludeWorstRelated(250); $userScore = array(); foreach ($stubs as $stub) { if ($stub) { $userScore = $r->getSuggestedUsers($stub); arsort($userScore); foreach ($userScore as $username => $score) { if (Recommendations::isAvailableUser($username)) { print wfTimestampNow() . " Adding recommendation to edit " . $stub->getText() . " for user " . $username . "\n"; $u = User::newFromId($username); if ($u && $u->getId()) { fwrite($f, $u->getId() . "\t" . $stub->getArticleId() . "\t" . $score); $reasons = $r->getSuggestionReason($username, $stub->getArticleId()); foreach ($reasons as $reason) { fwrite($f, "\t" . $reason); } fwrite($f, "\n"); } } } } } }