-- build a word tree (character occurrence tree) and walk it
pairs = {}
wordTree = {}
wordTreeP = wordTree
function p(m, s)
if s ~= nil then
for i = 1, s:len() do
local c = s:sub(i, i)
if c >= "a" and c <= "z" or c >= "A" and c <= "Z" then
local n = wordTreeP[c]
if n == nil then n = {} wordTreeP[c] = n end
wordTreeP = n
else
wordTreeP = wordTree
end
end
end
local c, n = next(wordTreeP)
return c
endBegan life as a copy of #1004708
test run test run with input download show line numbers
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
| ID | Author/Program | Comment | Date |
|---|---|---|---|
| 1297 | stefan | Scores 31.4% in the Maude test | 2016-08-27 16:23:13 |
| Snippet ID: | #1004710 |
| Snippet name: | Word Tree Predictor [Lua] |
| Eternal ID of this version: | #1004710/1 |
| Text MD5: | f04cf7cb3d77e1b1ac34773b8d60099b |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | Lua code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-08-28 14:44:44 |
| Source code size: | 492 bytes / 20 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1881 / 327 |
| Referenced in: | [show references] |