From 352b33fe21aa4e39c2418617db5a4532b55dc4d7 Mon Sep 17 00:00:00 2001 From: surmon-china Date: Sun, 23 Apr 2017 21:24:21 +0800 Subject: [PATCH] update --- dist/naive-bayes.js | 9 +++++---- lib/naive-bayes.js | 9 +++++---- package.json | 5 +++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/dist/naive-bayes.js b/dist/naive-bayes.js index e3f4020..493d60a 100644 --- a/dist/naive-bayes.js +++ b/dist/naive-bayes.js @@ -297,11 +297,12 @@ var NaiveBayes = function () { var classifier = new NaiveBayes(json.options); // override the classifier's state - STATE_KEYS.forEach(function (k) { - if (!json[k]) { - throw new Error('NaiveBayes.fromJson: JSON string is missing an expected property: \'' + k + '\'.'); + STATE_KEYS.forEach(function (key) { + if (json[key] == undefined) { + throw new Error('NaiveBayes.fromJson: JSON string is missing an expected property: \'' + key + '\'.'); + } else { + classifier[key] = json[key]; } - classifier[k] = json[k]; }); return classifier; diff --git a/lib/naive-bayes.js b/lib/naive-bayes.js index 97a34be..acbccf3 100644 --- a/lib/naive-bayes.js +++ b/lib/naive-bayes.js @@ -266,11 +266,12 @@ class NaiveBayes { const classifier = new NaiveBayes(json.options) // override the classifier's state - STATE_KEYS.forEach(k => { - if (!json[k]) { - throw new Error(`NaiveBayes.fromJson: JSON string is missing an expected property: '${k}'.`) + STATE_KEYS.forEach(key => { + if (json[key] == undefined) { + throw new Error(`NaiveBayes.fromJson: JSON string is missing an expected property: '${key}'.`) + } else { + classifier[key] = json[key] } - classifier[k] = json[k] }) return classifier diff --git a/package.json b/package.json index 7a341c0..5196ca1 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,13 @@ { "name": "naivebayes", - "version": "0.2.0", + "version": "0.3.0", "description": "Naive Bayes Classifier for node.js.", "main": "dist/naive-bayes.js", "scripts": { "dev": "nodemon --exec \"NODE_ENV=development node --harmony test.js\"", "build": "babel lib --out-dir dist", - "test": "node test.js" + "test": "node test.js", + "deploy": "git push && npm publish && git push --tags" }, "author": "Surmon", "license": "MIT",