static int ai_writeTripleFile(Collection triples, OutputStream out) ctex { print("Writing triple file"); new L names; new Map index; new ByteArrayOutputStream baos; PrintWriter writer = utf8printWriter(baos); int n = 0; for (TripleWeb w : triples) { ++n; S title = null; S moreInfo = quote(str(w.globalID())) + " " + quote(unnull(title)) + " " + quote(unnull(w.source())) + " " + (w.unverified() ? "u" : "v") + " " + w.created(); writer.write( ai_writeTripleFile_indexGet(names, index, w.a) + " " + ai_writeTripleFile_indexGet(names, index, w.b) + " " + ai_writeTripleFile_indexGet(names, index, w.c) + " " + moreInfo + "\n"); } //out.println(struct(names)); print("Have " + n2(names, "name") + ", " + toM(baos.size()) + "M buffered bytes"); PrintWriter writer2 = utf8printWriter(out); for (S s : names) writer2.println(quoteUnlessIdentifierOrInteger(s)); writer2.println(); baos.writeTo(out); ret n; } static int ai_writeTripleFile_indexGet(L names, Map index, S s) { Int i = index.get(s); if (i == null) { i = l(names); names.add(s); index.put(s, i); } ret i; }