<commit_before>/**
 * Internal dependencies.
 */

var syntax = require('./syntax');

/**
 * Context.
 *
 * @param {Object} node
 * @param {Object} parent node
 * @constructor
 */

function Context(node, parentNode) {
  this.node = node;
  this.parent = parentNode;
  this.children = [];
  this._score = 0;
}

/**
 * Add `num` to the context score.
 *
 * @param {Number} num
 * @api public
 */

Context.prototype.add = function(num) {
  this._score += num;
};

/**
 * Return the score of the current context
 * and all children combined together.
 *
 * @returns {Number}
 * @api public
 */

Context.prototype.totalScore = function() {
  var ret = this.score();

  this.children.forEach(function(child) {
    ret += child.totalScore();
  });

  return ret;
};

/**
 * Return the score of the context.
 *
 * @returns {Number}
 * @api public<commit_msg>Because 3 returns in 4 lines is fun, that's why<commit_after>/**
 * Internal dependencies.
 */

var syntax = require('./syntax');

/**
 * Context.
 *
 * @param {Object} node
 * @param {Object} parent node
 * @constructor
 */

function Context(node, parentNode) {
  this.node = node;
  this.parent = parentNode;
  this.children = [];
  this._score = 0;
}

/**
 * Add `num` to the context score.
 *
 * @param {Number} num
 * @api public
 */

Context.prototype.add = function(num) {
  this._score += num;
};

/**
 * Return the score of the current context
 * and all children combined together.
 *
 * @returns {Number}
 * @api public
 */

Context.prototype.totalScore = function() {
  return this.children.map(function(child) {
    return child.totalScore();
  }).reduce(function(a, b) {
    return a + b;
  }, this.score());
};

/**
 * Return the score of the context.
 *
 * @returns {Number}
 * @api public
{'fraction_non_alphanumeric': 0.1630558722919042, 'fraction_numerical': 0.002280501710376283, 'mean_word_length': 3.148936170212766, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7087543', 'n_tokens_mistral': 572, 'n_tokens_neox': 562, 'n_words': 162}