node-wordnet
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -129,2 +129,39 @@ var DataFile, IndexFile, Promise, WordNet, async, fs, path, | ||
WordNet.prototype.querySense = function(input, callback) { | ||
var pos, word, wordnet, _ref; | ||
wordnet = this; | ||
_ref = input.split('#'), word = _ref[0], pos = _ref[1]; | ||
return wordnet.lookup(input, function(results) { | ||
var i, sense, senseCounts, senses; | ||
senseCounts = {}; | ||
senses = (function() { | ||
var _i, _len, _results; | ||
_results = []; | ||
for (i = _i = 0, _len = results.length; _i < _len; i = ++_i) { | ||
sense = results[i]; | ||
pos = sense.pos; | ||
if (pos === 's') { | ||
pos = 'a'; | ||
} | ||
if (senseCounts[pos] == null) { | ||
senseCounts[pos] = 1; | ||
} | ||
_results.push(word + "#" + pos + "#" + senseCounts[pos]++); | ||
} | ||
return _results; | ||
})(); | ||
return callback(senses); | ||
}); | ||
}; | ||
WordNet.prototype.querySenseAsync = function(input) { | ||
var wordnet; | ||
wordnet = this; | ||
return new Promise(function(resolve, reject) { | ||
return wordnet.querySense(input, function(data) { | ||
return resolve(data); | ||
}); | ||
}); | ||
}; | ||
WordNet.prototype.lookupFromFiles = function(files, results, word, callback) { | ||
@@ -131,0 +168,0 @@ var file, wordnet; |
{ | ||
"name": "node-wordnet", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Node.js interface for Wordnet", | ||
@@ -5,0 +5,0 @@ "main": "lib/wordnet.js", |
@@ -80,3 +80,17 @@ Wordnet | ||
### querySense(query, callback) | ||
Queries WordNet to find all the senses of a given word, optionally with a | ||
part-of-speech. | ||
```javascript | ||
var wordnet = new WordNet() | ||
wordnet.querySense('axes#n', console.log); | ||
``` | ||
### querySenseAsync(query) | ||
Similar to `querySense(query, callback)` but returning a promise. | ||
Future work | ||
@@ -83,0 +97,0 @@ ----------- |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73127
706
99