added WNdb module to obtain WordNet files offline
This commit is contained in:
parent
518725c189
commit
017c0029f4
33
README.md
33
README.md
|
@ -10,7 +10,7 @@ Usage
|
|||
|
||||
```js
|
||||
var WordPOS = require('./wordpos'),
|
||||
wordpos = new WordPOS('dict');
|
||||
wordpos = new WordPOS();
|
||||
|
||||
wordpos.getAdjectives('The angry bear chased the frightened little squirrel.', function(result){
|
||||
console.log(result);
|
||||
|
@ -30,8 +30,16 @@ Installation
|
|||
|
||||
Get the script `wordpos.js` and use it. (npm module may be coming.)
|
||||
|
||||
You may also want to manually download [WordNet files](http://wordnet.princeton.edu/wordnet/download/current-version/). Unpack into folder (say `dict`). [natural](http://github.com/NaturalNode/natural) will auto-download WordNet files --
|
||||
but I've found this to be unreliable as some of the files get truncated, leading the program to hang.
|
||||
or use a git path in your package.json dependencies:
|
||||
```
|
||||
...
|
||||
"dependencies": {
|
||||
"wordpos": "git://github.com/moos/wordpos.git"
|
||||
},
|
||||
...
|
||||
```
|
||||
|
||||
As of version 0.1.1, WordNet DB files are obtained off-line through dependency provided by moos/WBdb module.
|
||||
|
||||
Note: `wordpos-bench.js` requires a [forked uubench](https://github.com/moos/uubench) module.
|
||||
|
||||
|
@ -212,22 +220,3 @@ License
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012, mooster@42at.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
{
|
||||
"name": "wordpos",
|
||||
"description": "wordpos is a set of part-of-speech utilities for Node.js using natural's WordNet module.",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"homepage": "https://github.com/moos/wordpos",
|
||||
"engines": {
|
||||
"node": ">=0.4.10"
|
||||
},
|
||||
"dependencies": {
|
||||
"natural": "latest",
|
||||
"underscore": ">=1.3.1"
|
||||
"underscore": ">=1.3.1",
|
||||
"WNdb": "git://github.com/moos/WNdb.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"uubench": "git://github.com/moos/uubench.git"
|
||||
},
|
||||
"repository" : {
|
||||
"type" : "git",
|
||||
"url" : "http://github.com/moos/wordpos.git"
|
||||
"url" : "git://github.com/moos/wordpos.git"
|
||||
},
|
||||
"author": "Moos <mooster@42at.com>",
|
||||
"keywords": ["natural", "language", "wordnet", "pos"],
|
||||
|
|
|
@ -3,7 +3,7 @@ var uubench = require('uubench'), // from: https://github.com/moos/uubench
|
|||
fs = require('fs'),
|
||||
_ = require('underscore')._,
|
||||
WordPOS = require('./wordpos'),
|
||||
wordpos = new WordPOS('dict');
|
||||
wordpos = new WordPOS();
|
||||
|
||||
suite = new uubench.Suite({
|
||||
type: 'fixed',
|
||||
|
|
|
@ -12,7 +12,8 @@ var _ = require('underscore')._,
|
|||
natural = require('natural'),
|
||||
WordNet = natural.WordNet,
|
||||
tokenizer = new natural.WordTokenizer(),
|
||||
stopwords = ' '+ natural.stopwords.join(' ') +' ';
|
||||
stopwords = ' '+ natural.stopwords.join(' ') +' ',
|
||||
WNdb = require('WNdb');
|
||||
|
||||
function normalize(word) {
|
||||
return word.toLowerCase().replace(/\s+/g, '_');
|
||||
|
@ -65,7 +66,11 @@ function get(isFn) {
|
|||
|
||||
|
||||
var WordPOS = function() {
|
||||
if (arguments.length == 0) {
|
||||
WordPOS.super_.call(this, WNdb.path);
|
||||
} else {
|
||||
WordPOS.super_.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
util.inherits(WordPOS, WordNet);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
var WordPOS = require('./wordpos'),
|
||||
wordpos = new WordPOS('dict');
|
||||
wordpos = new WordPOS();
|
||||
|
||||
var str = "The angry bear chased the frightened little squirrel",
|
||||
expected = {
|
||||
|
|
Loading…
Reference in New Issue