1 | -- a, b are the last 2 words |
2 | pairs = {} |
3 | word = {} |
4 | nword = 0 |
5 | function p(m, s) |
6 | if s ~= nil then |
7 | for i = 1, s:len() do |
8 | local c = s:sub(i, i) |
9 | if c >= "a" and c <= "z" or c >= "A" and c <= "Z" then |
10 | nword = nword+1 |
11 | word[nword] = c |
12 | else |
13 | if nword ~= 0 then |
14 | newWord(table.concat(word)) |
15 | word = {} |
16 | nword = 0 |
17 | end |
18 | end |
19 | end |
20 | end |
21 | local x = pairs[b] |
22 | if x ~= nil then return " "..x else return nil end |
23 | end |
24 | |
25 | function newWord(w) |
26 | a = b |
27 | b = w |
28 | --print("newWord "..w) |
29 | if a ~= nil then |
30 | pairs[a] = b |
31 | end |
32 | 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: | 667 / 221 |
Referenced in: | [show references] |