sbool webs_readTripleFileAsTriples_debug; static L webs_readTripleFileAsTriples(File f) { if (hasMultipleCores()) ret webs_readTripleFileAsTriples_parallel2(f); if (!f.exists()) ret ll(); Iterator it = linesFromFile(f); new L names; while (it.hasNext()) { S s = trim(it.next()); if (empty(s)) break; names.add(symbol(unquote(s))); } if (webs_readTripleFileAsTriples_debug) print("Have " + l(names) + " names"); new L triples; while (it.hasNext()) { S s = it.next(); pcall { addIfNotNull(triples, webs_readTripleFileAsTriples_line(s, names)); } } ret triples; } static TripleWeb webs_readTripleFileAsTriples_line(S s, L names) { L l = javaTokC(s); if (l(l) >= 8) { S source = intern(unquote(l.get(5))); O result = null; // result pcall { if (eq(get(l, 8), "(")) { int i = indexOf(l, ")", 9); if (i >= 0) result = safeUnstructure(joinWithSpace(subList(l, 9, i))); } } TripleWeb t = newTripleWebWithSourceAndResult(source, result); t.a = names.get(parseInt(l.get(0))); t.b = names.get(parseInt(l.get(1))); t.c = names.get(parseInt(l.get(2))); t.globalID(unquote(l.get(3))); // t.title = unquote(l.get(4)); // unused t.flags = eq(l.get(6), "v") ? 0 : TripleWeb.UNVERIFIED; t.created(parseLong(l.get(7))); ret t; } else if (webs_readTripleFileAsTriples_debug) print("Wrong number of tokens in line: " + l(l) + " - " + sfu(l)); null; }