#!/usr/bin/env narwhal /* * Copyright (c) 2009 Panagiotis Astithas * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ if (system.args.length != 2) { print("Usage: " + system.args[0] + " [tests1|tests2]"); } else { var speller = require('speller'); var spelltest = require('./spelltest'); var json = require('json'); var file = require("file"); // Train the language model first. var f = new file.Path(module.path).resolve("../bin/big.txt").open("r"); while ((temp = f.readLine()) != "") speller.train(temp); print(json.stringify(spelltest.test(spelltest[system.args[1]]))); }