Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Unified Diff: tools/lua/ngrams_aggregate.lua

Issue 1204283002: Add lua scripts for generating n-grams from SKPs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix comment Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/lua/ngrams.lua ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lua/ngrams_aggregate.lua
diff --git a/tools/lua/ngrams_aggregate.lua b/tools/lua/ngrams_aggregate.lua
new file mode 100644
index 0000000000000000000000000000000000000000..f8c93381495badfa80079858cf361afaf53650ae
--- /dev/null
+++ b/tools/lua/ngrams_aggregate.lua
@@ -0,0 +1,22 @@
+-- Aggregate the output from ngrams.lua.
+
+-- Get the data from all shards.
+counts = {}
+dofile("/tmp/lua-output")
+
+-- Put the data into a sortable "array".
+countArray = {}
+for ngram, count in pairs(counts) do
+ table.insert(countArray, {count, ngram})
+end
+
+-- Sort the data.
+function compare(a, b)
+ return a[1] > b[1]
+end
+table.sort(countArray, compare)
+
+-- Write the result.
+for i, countPair in ipairs(countArray) do
+ io.write(countPair[1], "\t", countPair[2], "\n")
+end
« no previous file with comments | « tools/lua/ngrams.lua ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698