Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

31
LINES

< > BotCompany Repo | #518 // Automated annotations (testing)

Lua code

get("#517") -- mergeTexts
get("#515") -- splitLines

trainingData = getSnippet("#2000015")
newData = getSnippet("#2000016")

function tryExactLookup()
  local annmap = {}
  for _, l in ipairs(trainingLines) do
    local _, _, ann, s = l:find("^(.*) | (.*)$")
    if ann then
      annmap[s] = ann
    else
      print("Unparsable: "..l)
    end
  end
  for i=1, n do
    annotations[i] = annotations[i] or annmap[newLines[i]]
  end
end

trainingLines = splitLines(trainingData)

newLines = splitLines(newData)
n = #newLines
annotations = {}

tryExactLookup()

for i=1, n do annotations[i] = annotations[i] or '' end
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: 611 / 138
Referenced in: [show references]