-- a, b are the last 2 words pairs = {} word = {} nword = 0 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 nword = nword+1 word[nword] = c else if nword ~= 0 then newWord(table.concat(word)) word = {} nword = 0 end end end end local x = pairs[b] if x ~= nil then return " "..x else return nil end end function newWord(w) a = b b = w --print("newWord "..w) if a ~= nil then pairs[a] = b end end
Began life as a copy of #1004710
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
No comments. add comment
Snippet ID: | #1004711 |
Snippet name: | Word 2-Gram Predictor [Lua] |
Eternal ID of this version: | #1004711/1 |
Text MD5: | 4624541602d9ee3dce3ad734b2a3ac41 |
Author: | stefan |
Category: | javax / a.i. |
Type: | Lua code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-08-27 16:50:54 |
Source code size: | 627 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 598 / 197 |
Referenced in: | [show references] |