<commit_before>'use strict'
module.exports = (target, subs, tree, key) => {
  const path = target.path()
  var eligable, level, length
  for (let field in subs) {
    if (field[0] !== '$') {
      if (!length) { length = path.length }
      const glob = field.split('.')
      const l = glob.length
      if (length >= l) {
        if (!level || l >= level) {
          const delta = length - l
          let score = 0
          for (let i = l - 1, weight = 0; i >= 0; i--) {
            const key = glob[i]
            weight++
            if (key === path[i + delta]) {
              score += weight
            } else if (key !== '*') {
              break
            }
          }
          if (score) {
            if (!eligable) { eligable = [] }
            if (!(l in eligable)) { eligable[l] = [] }
            eligable[l][score] = field
            level = l
          }
        }
      }
    }
  }
  if (eligable) {
    const candidates = eligable[level]
    return candidates[candidates.length - 1]
  }
}
<commit_msg>updated switch to check for truthy<commit_after>'use strict'
module.exports = (target, subs, tree, key) => {
  if (target.compute()) {
    const path = target.path()
    var eligable, level, length

    for (let field in subs) {
      if (field[0] !== '$') {
        if (!length) { length = path.length }
        const glob = field.split('.')
        const l = glob.length
        if (length >= l) {
          if (!level || l >= level) {
            const delta = length - l
            let score = 0
            for (let i = l - 1, weight = 2; i >= 0; i--) {
              const key = glob[i]
              weight++
              if (key === path[i + delta]) {
                score += weight
              } else if (key === '*') {
                score += 1
              } else {
                break
              }
            }
            if (score) {
              if (!eligable) { eligable = [] }
              if (!(l in eligable)) { eligable[l] = [] }
              eligable[l][score] = field
              level = l
            }
          }
        }
      }
    }

    if (eligable) {
      const candidates = eligable[level]
      return candidates[candidates.length - 1]
    }
  }
}

{'fraction_non_alphanumeric': 0.14298520842671447, 'fraction_numerical': 0.00582698341550874, 'mean_word_length': 1.2706002034587995, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '788776', 'n_tokens_mistral': 685, 'n_tokens_neox': 653, 'n_words': 192}