33 lines
9.2 KiB
JSON
33 lines
9.2 KiB
JSON
{
|
|
"name": "nodehun",
|
|
"version": "0.0.5",
|
|
"description": "The Hunspell binding for nodejs that exposes as much of hunspell as possible and also adds new features.",
|
|
"main": "lib/index.js",
|
|
"directories": {
|
|
"test": "tests"
|
|
},
|
|
"scripts": {
|
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
},
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "https://github.com/nathanjsweet/nodehun.git"
|
|
},
|
|
"keywords": [
|
|
"spellcheck",
|
|
"spell",
|
|
"hunspell"
|
|
],
|
|
"author": {
|
|
"name": "Nathan Sweet"
|
|
},
|
|
"license": "MIT",
|
|
"readme": "Nodehun\n=======\n\nInstallation\n------------\nNodehun has no \"node_module\" dependencies (yet), so it can either be installed via npm or simply checked out of git. You'll need [node-gyp](https://github.com/TooTallNate/node-gyp) to build. Nodehun should work on Windows or Unix. You'll also need to make sure that libuv source\ncode is on your system. Usually having node installed is enough, but there are weird cases.\n\t\n\tnpm install nodehun\n\tcd src\n\tnode-gyp configure\n\tnode-gyp build\n\t\n\nIntroduction\n------------\nYes there are already two nodejs spell checkers based of off hunspell, but one doesn't seem to even be supported anymore, and the other seems to only support simple spelling suggestions. Nodehun aims to expose as much of hunspell's functionality as possible in an easy to understand and maintain way, while also offering additional functionality not even present in hunspell.\n\nSpell Suggest and Initialization, directory based\n-------------------------------------------------\nInitializing nodehun is very easy, it will automatically find the dictionary you are looking for as long as it is inside the dictionaries folder (nodehun ships with US english and Canadian English, but tons of languages are available for free at [open office](http://extensions.services.openoffice.org/dictionary), you should be able to just drop any of open office's dictionary folders into nodehun's dictionary folder and it should automatically work, see the readme file in the dictionaries folder for more directions). From initialization there are only a few built in objects that come with nodehun, most of the functionality you will use are methods in the built in object \"Dictionary\". Simple spell suggest is very easy.\n\t \n\tvar nodehun = require('nodehun'),\n\t USDictionary = new nodehun.Dictionary('en_US');\n\t\t\n\tUSDictionary.spellSuggest('color',function(a,b){\n\t\tconsole.log(a,b);\n\t\t// because \"color\" is a defined word in the US English dictionary\n\t\t// the output will be: true, null\n\t});\n\t\n\tUSDictionary.spellSuggest('calor',function(a,b){\n\t\tconsole.log(a,b);\n\t\t// because \"calor\" is not a defined word in the US English dictionary\n\t\t// the output will be: false, \"carol\"\n\t});\n\t\nSpell Suggest and Initialization, buffer based.\n-------------------------------------------------\nAnother option for initializing a nodehun dictionary is to pass the raw string output of both the affix and dictionary files of a particular language. This allows you to use an alternate data-store than the servers file system. Please do not actually use `readFileSync`.\n\t \n\tvar nodehun = require('nodehun'),\n\t fs = require('fs'),\n\t USDictionary = new nodehun.Dictionary(fs.readFileSync('./en_US.aff').toString(),fs.readFileSync('./en_US.dic').toString());\n\t\t\n\tUSDictionary.spellSuggest('color',function(a,b){\n\t\tconsole.log(a,b);\n\t\t// because \"color\" is a defined word in the US English dictionary\n\t\t// the output will be: true, null\n\t});\n\t\n\tUSDictionary.spellSuggest('calor',function(a,b){\n\t\tconsole.log(a,b);\n\t\t// because \"calor\" is not a defined word in the US English dictionary\n\t\t// the output will be: false, \"carol\"\n\t});\n\t\nSpell Suggestions\n-----------------\nNodehun also offers a method that returns an array of words that could possibly match a misspelled word, ordered by most likely to be correct.\n\t\n\tvar nodehun = require('nodehun'),\n\t\tUSDictionary = new nodehun.Dictionary('en_US');\n\t\n\tUSDictionary.spellSuggestions('color',function(a,b){\n\t\tconsole.log(a,b);\n\t\t// because \"color\" is a defined word in the US English dictionary\n\t\t// the output will be: true, []\n\t});\n\n\tUSDictionary.spellSuggest('calor',function(a,b){\n\t\tconsole.log(a,b);\n\t\t// because \"calor\" is not a defined word in the US English dictionary\n\t\t// the output will be: false, [ 'carol','valor','color','cal or','cal-or','caloric','calorie']\n\t});\n\t\nAdd Dictionary\n--------------\nNodehun also can add another dictionary on top of an existing dictionary object at runtime (this means it is not permanent) in order to merge two dictionaries.\n\t\n\tvar nodehun = require('nodehun'),\n\t\tUSDictionary = new nodehun.Dictionary('en_US');\n\t\n\tUSDictionary.spellSuggest('colour',function(a,b){\n\t\tconsole.log(a,b);\n\t\t// because \"colour\" is not a defined word in the US English dictionary\n\t\t// the output will be: false, \"color\"\n\t});\n\t\n\tUSDictionary.addDictionary('en_CA',function(a,b){\n\t\tconsole.log(a,b);\n\t\t// because the Canadian English dictionary exists,\n\t\t// the output will be: true, 'en_CA'\n\t\tUSDictionary.spellSuggest('colour',function(a,b){\n\t\t\tconsole.log(a,b);\n\t\t\t// because \"colour\" is a defined word in the Canadian English dictionary\n\t\t\t// the output will be: true, null\n\t\t});\n\t\t\n\t});\n\t\nAdd Dictionary, buffer based\n----------------------------\nSimilar to the alternate means of initializing a nodehun dictionary you can also add a dictionary to an existing one with a raw string, even if the original dictionary wasn't initialized that way. NOTICE: the second argument is now the boolean value `true`, which indicates that the string being passed is a dictionary; if the value was `false` then it would treat the first argument as a path. The callback can be either the 2nd or 3rd argument, if it is the second argument the function will assume you've passed a \"path\" string. Once again, please do not actually use `readFileSync`.\n\t\n\tvar nodehun = require('nodehun'),\n\t fs = require('fs'),\t \n\t USDictionary = new nodehun.Dictionary('en_US');\n\t\n\tUSDictionary.spellSuggest('colour',function(a,b){\n\t\tconsole.log(a,b);\n\t\t// because \"colour\" is not a defined word in the US English dictionary\n\t\t// the output will be: false, \"color\"\n\t});\n\t\n\tUSDictionary.addDictionary(fs.readFileSync('./en_CA.dic').toString(),true,function(a,b){\n\t\tconsole.log(a,b);\n\t\t// because the Canadian English dictionary exists,\n\t\t// the output will be: true, 'en_CA'\n\t\tUSDictionary.spellSuggest('colour',function(a,b){\n\t\t\tconsole.log(a,b);\n\t\t\t// because \"colour\" is a defined word in the Canadian English dictionary\n\t\t\t// the output will be: true, null\n\t\t});\n\t\t\n\t});\n\t\n\nAdd Word\n--------\nNodehun can also add a single word to a dictionary at runtime (this means it is not permanent) in order to have a custom runtime dictionary. If you know anything about Hunspell you can also add flags to the word.\n\t\n\tvar nodehun = require('nodehun'),\n\t\tUSDictionary = new nodehun.Dictionary('en_US');\n\t\n\tUSDictionary.spellSuggest('colour',function(a,b){\n\t\tconsole.log(a,b);\n\t\t// because \"colour\" is not a defined word in the US English dictionary\n\t\t// the output will be: false, \"color\"\n\t});\n\t\n\tUSDictionary.addWord('colour',function(a,b){\n\t\tconsole.log(a,b);\n\t\t// if the method succeeded then\n\t\t// the output will be: true, 'colour'\n\t\tUSDictionary.spellSuggest('colour',function(a,b){\n\t\t\tconsole.log(a,b);\n\t\t\t// because \"colour\" has been added to the US dictionary object.\n\t\t\t// the output will be: true, null\n\t\t});\n\t\t\n\t});\n\t\nRemove Word\n-----------\nNodehun can also remove a single word from a dictionary at runtime (this means it is not permanent) in order to have a custom runtime dictionary. If you know anything about Hunspell this method will ignore flags and just strip words that match.\n\t\n\tvar nodehun = require('nodehun'),\n\t\tUSDictionary = new nodehun.Dictionary('en_US');\n\t\n\tUSDictionary.spellSuggest('color',function(a,b){\n\t\tconsole.log(a,b);\n\t\t// because \"color\" is a defined word in the US English dictionary\n\t\t// the output will be: true, null\n\t});\n\t\n\tUSDictionary.removeWord('color',function(a,b){\n\t\tconsole.log(a,b);\n\t\t// if the method succeeded then\n\t\t// the output will be: true, 'color'\n\t\tUSDictionary.spellSuggest('color',function(a,b){\n\t\t\tconsole.log(a,b);\n\t\t\t// because \"color\" has been removed from the US dictionary object.\n\t\t\t// the output will be: false, \"colors\"\n\t\t\t// note that plurals are considered separte words.\n\t\t});\n\t\t\n\t});\n\t\nAdd Dictionary Permanently and Add Word Permanently\n---------------------------------------------------\nI have deprecated and scrapped these methods as they really violate good design philosophy of a well written node module. These methods can both be easily replicated using node itself. I am trying to move nodehun away from needing files at all, as they are a poor data-store for a distributed system.",
|
|
"readmeFilename": "readme.md",
|
|
"bugs": {
|
|
"url": "https://github.com/nathanjsweet/nodehun/issues"
|
|
},
|
|
"_id": "nodehun@0.0.5",
|
|
"_from": "nodehun@"
|
|
}
|