<commit_before>'use strict';

const Immutable = require('immutable');

const rules = [
  {
    match: (line) => true,
    edit: (line) => line
  }
];

const applyRulesToLines = (lines, rules) => {
  return lines.map((line) => {
    const matchedRules = rules.filter((rule) => rule.match(line));
    return matchedRules.reduce((acc, rule) => rule.edit(acc), line);
  });
};

const applyHeuristics = (cff, heuristics) => applyRulesToLines(cff.get('lines'), rules);

module.exports = applyHeuristics;<commit_msg>[core] Heuristics: fixed bug that return undefinedfixed bug that returned undefined when line didn't match any given rule insted of returnig unchanged line.<commit_after>'use strict';

const Immutable = require('immutable');

const applyRulesToLines = (lines, rules) => {
  return lines.map((line) => {
    const matchedRules = rules.filter((rule) => rule.match(line));
    return matchedRules.length > 0 ?
      matchedRules.reduce((acc, rule) => rule.edit(acc), line) : line;
  });
};

const applyHeuristicRulesToCFF = (cff, rules) => {
  const editedLines = applyRulesToLines(cff.get('lines'), rules || []);
  return cff.set('lines', editedLines);
};

module.exports = applyHeuristicRulesToCFF;
{'fraction_non_alphanumeric': 0.15671641791044777, 'fraction_numerical': 0.0008291873963515755, 'mean_word_length': 4.802884615384615, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '1749209', 'n_tokens_mistral': 380, 'n_tokens_neox': 374, 'n_words': 93}