• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1-- Aggregate the output from ngrams.lua.
2
3-- Get the data from all shards.
4counts = {}
5dofile("/tmp/lua-output")
6
7-- Put the data into a sortable "array".
8countArray = {}
9for ngram, count in pairs(counts) do
10  table.insert(countArray, {count, ngram})
11end
12
13-- Sort the data.
14function compare(a, b)
15  return a[1] > b[1]
16end
17table.sort(countArray, compare)
18
19-- Write the result.
20for i, countPair in ipairs(countArray) do
21  io.write(countPair[1], "\t", countPair[2], "\n")
22end
23