static int ai_writeTripleFile(Collection<TripleWeb> triples, OutputStream out) ctex { print("Writing triple file"); new L<S> names; new Map<S, Int> index; ai_writeTripleFile_precollectNames(names, index, triples); 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(); O result = w.result(); if (result != null) moreInfo += " (" + sfu(result) + ")"; 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"); } writer.flush(); //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(); writer2.flush(); baos.writeTo(out); ret n; } static int ai_writeTripleFile_indexGet(L<S> names, Map<S, Int> index, S s) { Int i = index.get(s); if (i == null) { i = l(names); names.add(s); index.put(s, i); } ret i; } static void ai_writeTripleFile_precollectNames(L<S> names, Map<S, Int> index, Collection<TripleWeb> triples) { for (TripleWeb w : triples) { ai_writeTripleFile_indexGet(names, index, w.a); ai_writeTripleFile_indexGet(names, index, w.b); ai_writeTripleFile_indexGet(names, index, w.c); } sortInPlaceIC(names); index.clear(); for i over names: index.put(names.get(i), i); }
Began life as a copy of #1011763
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1013308 |
Snippet name: | ai_writeTripleFile |
Eternal ID of this version: | #1013308/15 |
Text MD5: | 9cb716377c5b23c5fd3e73aca52c5787 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-01-01 05:38:58 |
Source code size: | 1830 bytes / 53 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 422 / 467 |
Version history: | 14 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |