-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.php
35 lines (28 loc) · 906 Bytes
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
require_once("vendor/autoload.php");
require_once("traversal.php");
require_once("queryGraph.php");
// TODO: Hard-coded config
$conn = r\connect("localhost");
$candidates = array(new Candidate(new Term(Term::TYPE_ROW), $conn));
$conn->close();
$numIterations = 50;
for ($i = 0; $i < $numIterations; ++$i) {
$candidates = computeNextGen($candidates);
$avgScore = 0.0;
foreach ($candidates as $c) {
$avgScore += $c->score;
}
$avgScore /= count($candidates);
echo "Gen " . ($i+2) . ": " . count($candidates) . " candidates. Avg score: " . $avgScore . " Max score: " . $candidates[0]->score . "\n";
}
echo "Top candidates:\n";
echo "Score\tQuery\n";
for ($i = 0; $i < 5; ++$i) {
echo round($candidates[$i]->score);
echo "\t";
echo $candidates[$i]->printedTerm;
echo "\n";
echo "\t-> " . print_r($candidates[$i]->results, true);
echo "\n";
}