<commit_before>'use strict';

const debug      = require('debug')('shiba:cmd:prob');
const BustParser = require('./BustParser').parser;
const Lib        = require('../Lib');

function Prob() {
}

Prob.prototype.handle = function*(client, msg, input) {

  let qry;
  try {
    qry = BustParser.parse(input);
  } catch(err) {
    client.doSay('wow. very usage failure. such retry');
    return;
  }

  debug('Prob parse result: ' + JSON.stringify(qry));

  let res = 1;
  if (qry.hasOwnProperty('min') && qry.min > 0)
    res = Lib.winProb(qry.min);
  if (qry.hasOwnProperty('max'))
    res -= Lib.winProb(qry.max+1);

  let line = 'Probability of ' + input + ': ' + res;
  client.doSay(line);
};

module.exports = exports = Prob;<commit_msg>Improve !prob<commit_after>'use strict';

const debug      = require('debug')('shiba:cmd:prob');
const BustParser = require('./BustParser').parser;
const Lib        = require('../Lib');

function Prob() {
}

Prob.prototype.handle = function*(client, msg, input) {

  let qry;
  try {
    qry = BustParser.parse(input);
  } catch(err) {
    client.doSay('wow. very usage failure. such retry');
    return;
  }

  debug('Prob parse result: ' + JSON.stringify(qry));

  let res = 1;
  if (qry.hasOwnProperty('min') && qry.min > 0)
    res = Lib.winProb(qry.min);
  if (qry.hasOwnProperty('max'))
    res -= Lib.winProb(qry.max ? qry.max+1 : 100);
  res *= 100;

  let line = 'Probability of ' + input + ': ' + res.toFixed(6) + '%';
  client.doSay(line);
};

module.exports = exports = Prob;
{'fraction_non_alphanumeric': 0.18467583497053044, 'fraction_numerical': 0.008513425016371971, 'mean_word_length': 3.353276353276353, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '592112', 'n_tokens_mistral': 580, 'n_tokens_neox': 543, 'n_words': 118}