Comparing version 0.0.60 to 0.0.61
@@ -74,2 +74,6 @@ /* | ||
function getClassifications(observation) { | ||
return this.classifier.getClassifications(this.textToFeatures(observation)); | ||
} | ||
function classify(observation) { | ||
@@ -110,2 +114,3 @@ return this.classifier.classify(this.textToFeatures(observation)); | ||
Classifier.prototype.save = save; | ||
Classifier.prototype.getClassifications = getClassifications; | ||
Classifier.restore = restore; | ||
@@ -112,0 +117,0 @@ Classifier.load = load; |
{ | ||
"name": "natural", | ||
"description": "General natural language (tokenizing, stemming, classification, inflection, phonetics, tfidf, WordNet) facilities for node.", | ||
"version": "0.0.60", | ||
"version": "0.0.61", | ||
"engines": { | ||
@@ -18,9 +18,13 @@ "node": ">=0.2.6" | ||
"keywords": ["natural", "language", "porter", "lancaster", "stemmer", "bayes", | ||
"classifier", "phonetic", "metaphone", "inflector", "wordnet", "tf-idf"], | ||
"classifier", "phonetic", "metaphone", "inflector", "wordnet", "tf-idf", | ||
"logistic", "regression"], | ||
"main": "./lib/natural/index.js", | ||
"maintainers": [{ | ||
"name": "Chris Umbel", | ||
"email": "chris@chrisumbel.com", | ||
"web": "http://www.chrisumbel.com" | ||
"name": "Chris Umbel", | ||
"email": "chris@chrisumbel.com", | ||
"web": "http://www.chrisumbel.com" | ||
}, { | ||
"name": "Rob Ellis", | ||
"email": "rob@silentrob.me" | ||
}] | ||
} |
@@ -42,2 +42,17 @@ /* | ||
it('should provide all classification scores', function() { | ||
var classifier = new natural.BayesClassifier(); | ||
classifier.addDocument(['fix', 'box'], 'computing'); | ||
classifier.addDocument(['write', 'code'], 'computing'); | ||
classifier.addDocument(['script', 'code'], 'computing'); | ||
classifier.addDocument(['write', 'book'], 'literature'); | ||
classifier.addDocument(['read', 'book'], 'literature'); | ||
classifier.addDocument(['study', 'book'], 'literature'); | ||
classifier.train(); | ||
expect(classifier.getClassifications('i write code')[0].label).toBe('computing'); | ||
expect(classifier.getClassifications('i write code')[1].label).toBe('literature'); | ||
}); | ||
it('should classify with arrays', function() { | ||
@@ -44,0 +59,0 @@ var classifier = new natural.BayesClassifier(); |
@@ -43,2 +43,17 @@ /* | ||
it('should provide all classification scores', function() { | ||
var classifier = new natural.LogisticRegressionClassifier(); | ||
classifier.addDocument(['fix', 'box'], 'computing'); | ||
classifier.addDocument(['write', 'code'], 'computing'); | ||
classifier.addDocument(['script', 'code'], 'computing'); | ||
classifier.addDocument(['write', 'book'], 'literature'); | ||
classifier.addDocument(['read', 'book'], 'literature'); | ||
classifier.addDocument(['study', 'book'], 'literature'); | ||
classifier.train(); | ||
expect(classifier.getClassifications('i write code')[0].label).toBe('computing'); | ||
expect(classifier.getClassifications('i write code')[1].label).toBe('literature'); | ||
}); | ||
it('should classify with arrays', function() { | ||
@@ -45,0 +60,0 @@ var classifier = new natural.LogisticRegressionClassifier(); |
242014
4704