Comments (7)
Quick Update: it works 😃 ! Thanks!
from wink-naive-bayes-text-classifier.
Hi @ignStonechat,
Since 'how are you' and 'how are you doing' are using all stop words, thus returns 'unknown' as they are removed from the pattern while matching.
Tried commenting this statement:
nlp.tokens.removeWords
ofnbc.definePrepTasks
it returns the desired intent"{\"intent\":\"greeting.feeling\",\"answers\":[\"Good, How is it going with you?\"],\"type\":\"text\"}"
Thanks for exploring and reaching out.
Cheers!
Rachna
Oh my god! Didn't even relize that! I just tried it with "natural" too and it posed the SAME problem! thank you so much for help u guys are amazing!
from wink-naive-bayes-text-classifier.
Also:
"how are you" is literally in the dataset
from wink-naive-bayes-text-classifier.
Thanks for sharing this @ignStonechat!
Could you help us reproduce this error? Sharing the code that you've written would help us find and debug the issue.
from wink-naive-bayes-text-classifier.
Alright! Also thank you so much for such quick response!
basically this is the JS file:
var Classifier = require( 'wink-naive-bayes-text-classifier' );
var nbc = Classifier();
var nlp = require( 'wink-nlp-utils' );
const fs = require('fs');
const random = require('random')
nbc.definePrepTasks( [
nlp.string.tokenize0,
nlp.tokens.removeWords,
nlp.tokens.stem
] );
nbc.defineConfig( { considerOnlyPresence: true, smoothingFactor: 0.5 } );
let dataset = JSON.parse(fs.readFileSync('dataset.json', 'utf-8'));
for (let i = 0; i < dataset.length; i++) {
for (let j = 0; j < dataset[i].utterances.length; j++) {
nbc.learn(dataset[i].utterances[j], JSON.stringify({ intent: dataset[i].intent ,answers: dataset[i].answers, type: dataset[i].type }))
}
}
nbc.consolidate();
let answer = JSON.parse(nbc.computeOdds('how are ya')[0][0]);
if (answer.type === "function") {
switch (answer.intent) {
case "time_now":
console.log(answer.answers[random.int(min = 0, max = answer.answers.length - 1)] + time_now());
break;
default:
console.log('wat');
break;
}
} else {
console.log(answer);
}
function time_now() {
var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
var month = new Array();
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";
return `${today.getHours()}:${today.getMinutes()} | ${today.getDate()} ${month[today.getMonth()]}`
}
And here is the dataset file:
[
{
"intent": "greeting.hello",
"utterances": ["hey", "hello", "wassup", "good morning"],
"answers": ["Hello!", "Hey!"],
"type": "text"
},
{
"intent": "greeting.feeling",
"utterances": ["how are you", "how are you bud", "how is it going", "how are you doing"],
"answers": ["Good, How is it going with you?"],
"type": "text"
},
{
"intent": "greeting.bye",
"utterances": ["good bye", "bye", "see you later", "cya", "gbye"],
"answers": ["Good Bye!", "See you later!"],
"type": "text"
},
{
"intent": "time_now",
"utterances": ["what time is it", "what is the time", "tell me the time"],
"answers": ["Right now, It is: ", "It is: "],
"type": "function"
}
]
from wink-naive-bayes-text-classifier.
Thanks for sharing this @ignStonechat!
Could you help us reproduce this error? Sharing the code that you've written would help us find and debug the issue.
Are you having trouble with it too?
from wink-naive-bayes-text-classifier.
Hi @ignStonechat,
Since 'how are you' and 'how are you doing' are using all stop words, thus returns 'unknown' as they are removed from the pattern while matching.
Tried commenting this statement: nlp.tokens.removeWords
of nbc.definePrepTasks
it returns the desired intent "{\"intent\":\"greeting.feeling\",\"answers\":[\"Good, How is it going with you?\"],\"type\":\"text\"}"
Thanks for exploring and reaching out.
Cheers!
Rachna
from wink-naive-bayes-text-classifier.
Related Issues (10)
- Is word distance counted? HOT 12
- Is bayes suitable for bank transaction categorisation? HOT 7
- computeOdds between 0 and 1 HOT 1
- Can I do "Open Questions" with wink? HOT 8
- Consider instantiating textNBC when setting module.exports HOT 2
- Show percentages for different classifications? HOT 2
- update wink's link to point to winkjs.org
- update copyright notice year in README & License Header
- change "homepage" in package.json to winkjs.org
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wink-naive-bayes-text-classifier.