| 1 | get("#517") -- mergeTexts
 | 
| 2 | get("#515") -- splitLines
 | 
| 3 | |
| 4 | trainingData = getSnippet("#2000015")
 | 
| 5 | newData = getSnippet("#2000016")
 | 
| 6 | |
| 7 | function tryExactLookup() | 
| 8 |   local annmap = {}
 | 
| 9 | for _, l in ipairs(trainingLines) do | 
| 10 |     local _, _, ann, s = l:find("^(.*) | (.*)$")
 | 
| 11 | if ann then | 
| 12 | annmap[s] = ann | 
| 13 | else | 
| 14 |       print("Unparsable: "..l)
 | 
| 15 | end | 
| 16 | end | 
| 17 | for i=1, n do | 
| 18 | annotations[i] = annotations[i] or annmap[newLines[i]] | 
| 19 | end | 
| 20 | end | 
| 21 | |
| 22 | trainingLines = splitLines(trainingData) | 
| 23 | |
| 24 | newLines = splitLines(newData) | 
| 25 | n = #newLines | 
| 26 | annotations = {}
 | 
| 27 | |
| 28 | tryExactLookup() | 
| 29 | |
| 30 | for i=1, n do annotations[i] = annotations[i] or '' end | 
| 31 | print(mergeTexts(annotations, newLines)) | 
test run test run with input download show line numbers
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #518 | 
| Snippet name: | Automated annotations (testing) | 
| Eternal ID of this version: | #518/1 | 
| Text MD5: | 671703641fc8c626fe8f3957d8c97353 | 
| Author: | stefan | 
| Category: | |
| Type: | Lua code | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2015-03-11 15:50:40 | 
| Source code size: | 686 bytes / 31 lines | 
| Pitched / IR pitched: | No / Yes | 
| Views / Downloads: | 929 / 211 | 
| Referenced in: | [show references] |