!7 set flag NoComputerID. set flag LeanMode. sS url = "https://github.com/stefan-reich/smartbot/releases/download/1/triples.gz"; sclass InfoTriple { S a, b, c; // noun, verb, noun S globalID; // 16 character global ID bool verified; // is it reliable information? long created; // unix timestamp S source; // further source info toString { ret "[" + globalID + "] " + ai_renderTriple(a, b, c); } } static new L triples; p { programID = #1012438; File file = getProgramFile("triples-1.gz"); if (fileSize(file) == 0) { print("Downloading triples (9 MB)."); loadBinaryPageToFile(url, file); } else print("Triples already downloaded."); print("Parsing."); time { // Read names Iterator it = linesFromFile(file); new L names; while (it.hasNext()) { S s = trim(it.next()); if (empty(s)) break; names.add(unquote(s)); } // Read triples triples = new L; while (it.hasNext()) { S s = it.next(); pcall { addIfNotNull(triples, readTriple(s, names)); } } } print("Have " + l(triples) + " triples"); print("Some random triples:"); print(); pnl(selectRandom(triples, 10)); } static InfoTriple readTriple(S s, L names) { L l = javaTokC(s); if (l(l) == 8) { new InfoTriple t; t.a = javaIntern(names.get(parseInt(l.get(0)))); t.b = javaIntern(names.get(parseInt(l.get(1)))); t.c = javaIntern(names.get(parseInt(l.get(2)))); t.globalID = unquote(l.get(3)); // t.title = unquote(l.get(4)); // unused t.source = javaIntern(unquote(l.get(5))); t.verified = eq(l.get(6), "v"); t.created = parseLong(l.get(7)); ret t; } null; }