<commit_before><html>
<body>

<?php
class Comment {

	public $userName;
	public $storyName;
	public $storyURL;
	public $commentContent;
	public $commentLikes;
	public $bestConfidence;

}

class Thread {
	public $threadID;
	public $threadURL;
	public $threadName;
}

//comment sorting comparison
function cmp($a, $b)
{
	$a = $a->bestConfidence;
	$b = $b->bestConfidence;
    if ($a == $b) {
        return 0;
    }
    return ($a < $b) ? 1 : -1;
}

// Wilson scoring algorithm
function wilsonScore($likes, $dislikes)
{
	$n = $likes + $dislikes;
	if ($n == 0){
		return 0;
	}
	$z = 1; //1.0 = 85%, 1.6 = 95%
	$phat = $likes / $n;
	$score = sqrt($phat+$z*$z/(2*$n)-$z*(($phat*(1-$phat)+$z*$z/(4*$n))/$n))/(1+$z*$z/$n);
	return $score;
}

$response = file_get_contents("http://disqus.com/api/get_thread_list?user_api_key=az2jNJ6gR0S4fFI5g6teYJiEHdFEmzrm19iDJWpf5IYz8jFLUxHgHH2xg2uRKW31&api_version=1.1&forum_id=806579&limit=30");
//echo $response . "<br>";

$json_array = json_decode($response,true);
$threadIDs;

//Parse JSON and extract the Threads
for ($i = 0; $i < count($json_array["message"]); $i++) {

	$aThread = new Thread();
	
	$aThread->threadID = $json_array["message"][$i]["id"];
	$aThread->threadURL = $json_array["message"][$i]["url"];
	$aThread->threadName = $json_array["message"][$i]["title"];
	$threadIDs[$i] = $aThread;	
}

//Comments
for ($i = 0; $i < count($threadIDs); $i++) {

	//echo "Thread count: ".count($threadIDs)."<br>";
	//echo "Thread ID: ".$threadIDs[$i]." ".$i."<br>";

	$response = file_get_contents("http://disqus.com/api/get_thread_posts?user_api_key=az2jNJ6gR0S4fFI5g6teYJiEHdFEmzrm19iDJWpf5IYz8jFLUxHgHH2xg2uRKW31&api_version=1.1&thread_id=".$threadIDs[$i]->threadID."&limit=5");
<commit_msg>Added Reddit Hot ranking system<commit_after><html>
<body>

<?php
class Comment {

	public $userName;
	public $storyName;
	public $storyURL;
	public $commentContent;
	public $commentLikes;
	public $bestConfidence;

}

class Thread {
	public $threadID;
	public $threadURL;
	public $threadName;
}

//comment sorting comparison
function cmp($a, $b)
{
	$a = $a->bestConfidence;
	$b = $b->bestConfidence;
    if ($a == $b) {
        return 0;
    }
    return ($a < $b) ? 1 : -1;
}

// Wilson scoring algorithm
function wilsonScore($likes, $dislikes)
{
	$n = $likes + $dislikes;
	if ($n == 0){
		return 0;
	}
	$z = 1; //1.0 = 85%, 1.6 = 95%
	$phat = $likes / $n;
	$score = sqrt($phat+$z*$z/(2*$n)-$z*(($phat*(1-$phat)+$z*$z/(4*$n))/$n))/(1+$z*$z/$n);
	return $score;
}

function hotScore($likes, $time)
{
	$order = log(max($likes, 1), 10);
	$source = strtotime($time);
	$now = getdate();
	date_default_timezone_set('UTC');
	//$interval = date_diff($source, $now);
	$seconds = round(abs($now-$source));
	$score = round(order + sign * seconds / 45000, 7)
	return $score;
}

$response = file_get_contents("http://disqus.com/api/get_thread_list?user_api_key=az2jNJ6gR0S4fFI5g6teYJiEHdFEmzrm19iDJWpf5IYz8jFLUxHgHH2xg2uRKW31&api_version=1.1&forum_id=806579&limit=30");
//echo $response . "<br>";

$json_array = json_decode($response,true);
$threadIDs;

//Parse JSON and extract the Threads
for ($i = 0; $i < count($json_array["message"]); $i++) {

	$aThread = new Thread();
	
	$aThread->threadID = $json_array["message"][$i]["id"];
	$aThread->threadURL = $json_array["message"][$i]["url"];
	$aThread->threadName = $json_array["message"][$i]["title"];
	$threadIDs[$i] = $aThread;	
}

//Comments
for ($i = 0; $i < count($threadIDs); $i++) {

	//echo "Thread count: ".count($threadIDs)."<br>";
	//echo "Thread ID: ".$threadIDs[$i]." ".$i."<br>";

	$response = file_get_contents("http://disqus.com/api/get_thread_posts?user_api_key=az2jNJ6gR0S4fFI5g6teYJiEHdFEmzrm19iDJWpf5IYz8jFLUxHgHH2xg2uRKW31&api_version=1.1&thread_id=".$threadIDs[$i]->threadID."&limit=5");

{'fraction_non_alphanumeric': 0.2131885593220339, 'fraction_numerical': 0.03469279661016949, 'mean_word_length': 5.111650485436893, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1717076', 'n_tokens_mistral': 1723, 'n_tokens_neox': 1630, 'n_words': 271}