Git Product home page Git Product logo

Comments (7)

thestonechat avatar thestonechat commented on June 29, 2024 2

Quick Update: it works 😃 ! Thanks!

from wink-naive-bayes-text-classifier.

thestonechat avatar thestonechat commented on June 29, 2024 1

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

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.

thestonechat avatar thestonechat commented on June 29, 2024

Also:
image
"how are you" is literally in the dataset

from wink-naive-bayes-text-classifier.

prtksxna avatar prtksxna commented on June 29, 2024

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.

thestonechat avatar thestonechat commented on June 29, 2024

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.

thestonechat avatar thestonechat commented on June 29, 2024

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.

rachnachakraborty avatar rachnachakraborty commented on June 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.