<commit_before>/**
 * checks if there are scores which can be combined
 */
function checkValidity (scores) {
  if (scores == null) {
    throw new Error('There must be a scores object parameter')
  }
  if (Object.keys(scores).length <= 0) {
    throw new Error('At least one score must be passed')
  }
}

/**
 * Score canidate based on the mean value of two or more parent Qs.
 */
class MeanQ {

  /**
   * Returns the mean value of the given scores.
   * @param scores - obect that contains the keys and scores
   *                 for each used scoring method
   * @return mean value of given scores
   */
  combine (scores) {
    checkValidity(scores)

    var sum = 0
    Object.keys(scores).map((key, index, arr) => {
      sum += scores[key]
    })
    return sum / Object.keys(scores).length
  }
}

/**
 * Chooses the biggest score out of all possible scores
 */
class LargestQ {
<commit_msg>Refactor MeanQ to use Array.reduce().<commit_after>/**
 * checks if there are scores which can be combined
 */
function checkValidity (scores) {
  if (scores == null) {
    throw new Error('There must be a scores object parameter')
  }
  if (Object.keys(scores).length <= 0) {
    throw new Error('At least one score must be passed')
  }
}

/**
 * Score canidate based on the mean value of two or more parent Qs.
 */
class MeanQ {

  /**
   * Returns the mean value of the given scores.
   * @param scores - obect that contains the keys and scores
   *                 for each used scoring method
   * @return mean value of given scores
   */
  combine (scores) {
    checkValidity(scores)

    let values = Object.values(scores)
    let sum = values.reduce((sum, score) => sum + score, 0)
    return sum / values.length
  }
}

/**
 * Chooses the biggest score out of all possible scores
 */
class LargestQ {

{'fraction_non_alphanumeric': 0.1044776119402985, 'fraction_numerical': 0.002211166390270868, 'mean_word_length': 2.7014314928425356, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3475143', 'n_tokens_mistral': 551, 'n_tokens_neox': 531, 'n_words': 216}