Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including twss with all npm packages installed. Try it out:

var twss = require("twss")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

twss v0.1.6

That's what she said classifier

This is a node.js module that classifies if a sentence can be replied with "that's what she said".


npm install twss


var twss = require('twss');"Nice weather we're having today"); // false"Can you make it harder?");         // true"You're not going fast enough!");   // true



You change algorithm from the default naive bayes classifier (nbc) to a k-nearest neighbor algorithm (knn).

twss.algo = 'nbc';
twss.algo = 'knn';


If you want more obscure jokes to be accepted, you can set the "probability the sentence can be replied with twss" threshold. Be aware that a too low threshold may result in a lot of false-positives, and a too high threshold may result in a lot of false-negatives.

twss.threshold = 0.5;"You're hardly my first."); // false

twss.threshold = 0.3;"You're hardly my first."); // true

Additional functions


If you'd just like the probability that a sentence can be replied with "That's what she said" you can use the twss.probability function.

twss.probability("Behold, I come quickly."); // 0.956323045469951

Or just use the alias twss.prob

twss.prob("The juice keeps coming out of the wrong hole!") // 0.9961630818418142


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free