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))