From 7c24dcf3c6ad901f09c2951190f5eb3536c6ae5e Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Thu, 8 Nov 2012 02:35:26 -0500 Subject: [PATCH] coffeescript to filter by huge wordlist --- spellcheck.coffee | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 spellcheck.coffee diff --git a/spellcheck.coffee b/spellcheck.coffee new file mode 100644 index 0000000..0779356 --- /dev/null +++ b/spellcheck.coffee @@ -0,0 +1,30 @@ +fs = require 'fs' +async = require 'async' + +dict = {} + +async.waterfall [ + (callback) -> async.parallel [ + (callback) -> fs.readFile '/etc/dictionaries-common/words', 'utf8', callback + (callback) -> fs.readFile 'my_log_words', 'utf8', callback + ], callback + ([dictionary, log_words], callback) -> + for word in dictionary.split(/\n/) + dict[word] = true + good = [] + for line in log_words.split(/\n/) + word = line[line.lastIndexOf(' ')+1..] + if dict[word] + good.push word + if good.length == 8836 + return callback(null, good) + callback 'could find enough real words' + (words, callback) -> + for word in words + console.log word + callback() + ], (err) -> + if err + console.log err + process.exit 1 + process.exit 0 -- 1.7.10.4