From d10d87112dd954e0d4401241e8be28ef1e410e71 Mon Sep 17 00:00:00 2001 From: Tripindi Date: Wed, 12 Apr 2017 11:13:27 +0200 Subject: [PATCH 1/3] Update Classifier.js --- lib/Classifier.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Classifier.js b/lib/Classifier.js index 2782352..3c290c0 100644 --- a/lib/Classifier.js +++ b/lib/Classifier.js @@ -76,7 +76,7 @@ class Classifier { } }); - return result; + return {result: result, value: max}; } From fad783b4f98836ecc73c9c04bbd4a667f0c9455a Mon Sep 17 00:00:00 2001 From: Tripindi Date: Wed, 12 Apr 2017 12:08:19 +0200 Subject: [PATCH 2/3] Adding default fallback If the networks outputs a value under 0.9, the result will be "noMatch", wich means two things : 1- the network wasn't able to classify the input, so it might be a new intent or a random string. 2- If it's a false negative, you need to train the network with more strings After tests, 0.9 seems to be a good value, but it can be changed. I'm working on chatbots ( a lot ) so I'm trying to add my knowledge of the tools needed and the usage of them to make this module a better one. --- lib/Classifier.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Classifier.js b/lib/Classifier.js index 3c290c0..938ac31 100644 --- a/lib/Classifier.js +++ b/lib/Classifier.js @@ -75,8 +75,10 @@ class Classifier { max = current.value; } }); - - return {result: result, value: max}; + if(max < 0.9){ + result = "noMatch"; + } + return result; } From 7267210412f2256cfcbe8404694a5f3145ad0dbc Mon Sep 17 00:00:00 2001 From: Tripindi Date: Wed, 26 Apr 2017 12:39:50 +0200 Subject: [PATCH 3/3] return json network --- lib/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 1653eae..e069ac8 100644 --- a/lib/index.js +++ b/lib/index.js @@ -26,8 +26,14 @@ class NaturalSynaptic extends ClassifierBase { data.features = this.features; var payload = JSON.stringify(data); - - fs.writeFile(filename, payload, callback); + if(!filename){ + return payload; + } + else{ + fs.writeFile(filename, payload, callback); + return payload; + } + }; }