Transpiled version (2217L) is out of date.
!747 m { static new SnippetDB db; !include #1000989 // SnippetDB !include #1000988 // MultiSet p { db.importMySQLDump(gunzipToText("#1000673")); List<List<S>> rows = db.rowsOrderedBy("sn_created"); int i = 0; while (i < 3) { S text = db.getField(rows.get(i), "sn_text"); print(text + "\n==\n"); ++i; } /*for (int i = 0; i < Math.min(rows.size(), 10); i++) print(db.getField(rows.get(i), "sn_id"));*/ } static L<S> parse(S s) { return javaTok(s); } static S complete(S sentence1, S sentence2) { L<S> tok1 = parse(sentence1); L<S> tok2 = parse(sentence2); Map<S, MultiSet<S>> map = makeMMapPrefix(tok1, tok2); if (map == null) return null; new L<S> tok; tok.addAll(tok2.subList(0, tok2.size()-1)); for (int i = tok2.size()-1; i < tok1.size(); i++) { S t = tok1.get(i); MultiSet<S> set = map.get(t); tok.add(set == null ? t : set.getMostPopularEntry()); } return join(tok); } static Map<S, MultiSet<S>> makeMMapPrefix(L<S> tok1, L<S> tok2) { if (tok1.size() < tok2.size()) return null; Map<S, MultiSet<S>> map = new TreeMap<S, MultiSet<S>>(); for (int i = 1; i < tok2.size(); i += 2) { S t1 = tok1.get(i), t2 = tok2.get(i); MultiSet<S> set = map.get(t1); if (set == null) map.put(t1, new MultiSet<S>(t2)); else set.add(t2); } // match succeeds return map; } }
Began life as a copy of #1000987
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1000990 |
Snippet name: | Predict snippet continuation according to previous snippets (developing) |
Eternal ID of this version: | #1000990/1 |
Text MD5: | 5b75aceceee537fd287d5eeb95bd21af |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-09-14 17:50:35 |
Source code size: | 1542 bytes / 59 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 584 / 596 |
Referenced in: | [show references] |