Warning: session_start(): open(/var/lib/php/sessions/sess_8tur5isdc0hfoujqinpitc8dmh, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
static void ai_gc_scan(S root) {
ai_gc_clear();
time "GC Scan" {
ai_postTriple(root, "has GC distance", "0");
HashMap distances = lithashmap(root, 0.0);
LinkedList queue = litLinkedList(root);
S word;
while ping ((word = queue.poll()) != null) {
double d = distances.get(word);
for (WebNode node : indexedNodes(word)) {
for (WebRelation r : web_forwardRelations(node)) {
double dist = ai_gc_scan_distance(web_text(r), true);
if (!isNaN(dist))
ai_gc_scan_update(distances, queue, r.b, d+dist);
}
for (WebRelation r : web_backwardRelations(node)) {
double dist = ai_gc_scan_distance(web_text(r), false);
if (!isNaN(dist))
ai_gc_scan_update(distances, queue, r.a, d+dist);
}
}
}
Collection keys = keys(distances);
if (ai_inTestMode())
keys = keysSortedByValueDesc(distances);
for (S key : keys)
ai_postTriple(key, "has GC distance", formatDouble(distances.get(key), 1));
print(l(distances) + "/" + l(indexedTerms()) + " terms were reached in GC scan from " + quote(root) + ".");
}
}
// returns NaN if not a relevant connection
static double ai_gc_scan_distance(S rel, bool forward) {
if (forward) ret 1;
if (eqic(rel, "is")) ret 1;
ret nan();
}
static void ai_gc_scan_update(Map distances, L queue, WebNode n, double d) {
S text = ai_shortenForIndex(web_text(n));
Double od = distances.get(text);
if (od == null || d < od) {
distances.put(text, d);
queue.add(text);
}
}