Download Jar. Libraryless. Click here for Pure Java version (1559L/11K).
!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<InfoTriple> 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<S> it = linesFromFile(file); new L<S> 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<S> names) { L<S> 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; }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1012438 |
Snippet name: | Load & parse triples.gz from GitHub (a once-only 9 MB download) |
Eternal ID of this version: | #1012438/18 |
Text MD5: | b9071021a710f81d1d1963cd3c372534 |
Transpilation MD5: | 518607f84ca2ce4f8ed63364d1158115 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-12-05 13:55:00 |
Source code size: | 1821 bytes / 74 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 627 / 1709 |
Version history: | 17 change(s) |
Referenced in: | [show references] |