Warning: session_start(): open(/var/lib/php/sessions/sess_eihjce1j9pqh6ob0u438pp1evr, 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
!7
static double aiConceptsCacheInterval = 60;
concept Search {
S q, ip;
}
p {
db();
}
html {
print("Wiki URI: " + uri);
S vis = registerVisitor();
uri = dropSuffix("/", uri);
uri = dropPrefix("/", uri);
if (eq(uri, "sleep")) {
sleepSeconds(5);
ret "Slept 5, just for you.";
}
S q = trim(params.get("q"));
if (nempty(q))
cset(uniq(Search, +q, ip := getClientIP()), lastSeen := now());
if (eq(uri, "import")) {
triggerStandardAIImport();
ret "OK";
}
if (eq(uri, "searches")) {
ret htitle_h2("Latest Searches")
+ htable(map(func(Search s) { litorderedmap(Query := dynamize(s.q),
IP := dynamize(s.ip)) }, takeLast(10, sortedByFieldDesc("lastSeen", list(Search)))), false);
}
aiConceptsMap_clearCache(aiConceptsCacheInterval);
final Map map = aiConceptsMap_cached();
if (possibleGlobalID(uri)) {
// Serve concept
final AIConcept c = map.get(toLower(uri));
if (c == null)
ret "Concept not found: " + toLower(uri);
S html = htitle(c.name + " [" +
(nempty(c.comment) ? c.comment + " / " : "") + c.globalID + "]")
+ h2(htmlencode(aiConceptToString(c)));
/*html += ul(
"Image MD5: " + htmlencode(c.imageMD5)
);*/
if (nempty(c.imageMD5) && imageServerHas(c.imageMD5))
html += p(himg(imageServerLink(c.imageMD5)));
//L statements = [S s : trueStatements_cached() | containsIgnoreCase(s, c.globalID)];
L statements = [Statement s : loadTruth_cached() | containsIgnoreCase(s.text, c.globalID)];
if (nempty(statements))
html += h3("Statements about this") + ul(map(f statementToHTML, statements));
html += p(ahref("http://ai1.lol/wiki", "[All Concepts]"));
ret html;
}
S results = "";
if (nempty(q)) {
L l = imSearch(q);
if (empty(l))
results = h3("No search results for " + quote(q));
else
results = h3("Search results for " + quote(q))
+ ul(map(f aiConceptToHTML, l));
}
L l = sortedByFieldDesc(values(map), "imported");
S search =
p("Search term, question or statement:", style := "margin-top: 40px")
+ hform(htextinput("q", q, autofocus := 1, style := "text-align: center") + " " + hsubmit("Go"));
S line = "";
/*if (empty(results))*/ line = "See " + ahref("https://www.youtube.com/watch?v=gTlgZkc95IU", "Video") + ". " + ahref("http://ai1.lol/new", htmlencode("More videos & articles")) + "."
+ (webAuthed() ? " " + ahref("/wiki/import", "Import.") : "");
S concepts = ul(map(f aiConceptToHTML, l));
L statements = reversed(loadTruth_cached());
S relations = ul(map(f statementToHTML, statements));
ret htitle("Intelligence Machine")
+ hcenter2(
p(ahref("http://ai1.lol/", hTBImage(#1007526, "title", "Intelligence Machine")))
+ p(small("Yes, this is early, but it will work really soon :-) " + ahref("http://tinybrain.de/1007510", "Source."))
+ search)
+ (empty(line) ? "" : p(line))
+ results
+ htableRaw_valignTop(ll(ll(
h3("Concepts (" + l(l) + ")") + concepts,
h3("Relations (" + l(statements) + ")") + relations)), "border", "0")
+ hcenter2(p(hsmall(dropIncluding(vis, "
"))));
}
static S aiConceptToHTML(AIConcept c) {
ret dynamize(c.globalID) + " - " + htmlencode(aiConceptToString2(c));
}
static S statementToHTML(Statement s) {
ret dynamize(or2(s.possibleEnglishTranslation, "?") + " - " + s.text);
}