Libraryless. Click here for Pure Java version (2145L/14K/47K).
!752 static int sep = 0; p { load("sep"); } static S lua = [[ -- build a word tree (character occurrence tree) and walk it pairs = {} wordTree = {} wordTreeP = wordTree isSep = {} seps = "SEPS" for i = 1, seps:len() do isSep[seps:sub(i, i)] = true end function p(m, s) if s ~= nil then for i = 1, s:len() do local c = s:sub(i, i) if isSep[c] then wordTreeP = wordTree else local n = wordTreeP[c] if n == nil then n = {} wordTreeP[c] = n end wordTreeP = n end end end local c, n = next(wordTreeP) return c end ]]; static S strategy(S text) { if (sep >= 0x100) ret "done"; sep++; save("sep"); S seps = str((char) sep); print("Trying sep " + quote(seps)); ret lua.replace([["SEPS"]], luaQuote(seps)); } static void reset() { sep = 0; save("sep"); }
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004744 |
Snippet name: | Word Tree Predictor Strategy |
Eternal ID of this version: | #1004744/1 |
Text MD5: | 204d919e2e809ba6854b1c01995ba6ee |
Transpilation MD5: | f89279ce397c64e944b6ae219c9c7e14 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-09-11 23:14:35 |
Source code size: | 932 bytes / 47 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 666 / 1007 |
Referenced in: | #1004871 - Process "Brainstorm" [Sim Predict, dev.] |