static interface Algorithm { S predict(int max); void feed(S s); } static class LuaAlgo implements Algorithm { LuaValue predict, feed; S feeding; *(S code) { Sandbox s = luaSandbox(); evalLua(s, code); //print("KEYS: " + structure(s.keys())); predict = s.get("predict"); if (predict.isnil()) predict = s.get("p"); assertFalse(predict.isnil()); } public S predict(int max) { LuaValue s = predict.call(Lua.value(max), feeding != null ? Lua.value(feeding) : Lua.NIL); feeding = null; ret s.isnil() ? "" : s.tojstring(); } public void feed(S s) { feeding = s; } } static Algorithm makeLuaTextPredictAlgo(S desc) { ret new LuaAlgo(dropPrefix("L ", desc)); }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004709 |
Snippet name: | makeLuaTextPredictAlgo |
Eternal ID of this version: | #1004709/1 |
Text MD5: | 67feb78e11c7696b4572fb21d02c8900 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-08-28 15:49:57 |
Source code size: | 756 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 633 / 662 |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |