<commit_before>'use strict';
const iso3166 = require('iso-3166-2');
const evaljson = require('evaljson');
const objectPath = require('object-path');

const checkForSimpleAssignment = require('./../checkForSimpleAssignment');

module.exports = (params, data) => {
  try {
    var val = checkForSimpleAssignment(data, params.source);

    if (val === null) {
      val = evaljson(params, data).source;
    }

    let newVal = iso3166.country(val).name;

    if (!newVal) {
      if (params.error) {
        objectPath.set(data, params.error, `Unable to convert country: '${val}' is not a valid ISO 3166 value.`);
      }
    } else {
      if (params.target) {
        objectPath.set(data, params.target, newVal);
      } else {
        data = newVal;
      }
    }
  } catch (e) {
    throw(new Error('Unable to geohash \'' + params.source + '\': ' +
      e));
  }

  return data;
}
<commit_msg>fix minor type in error message of ISO 3166 filter<commit_after>'use strict';
const iso3166 = require('iso-3166-2');
const evaljson = require('evaljson');
const objectPath = require('object-path');

const checkForSimpleAssignment = require('./../checkForSimpleAssignment');

module.exports = (params, data) => {
  try {
    var val = checkForSimpleAssignment(data, params.source);

    if (val === null) {
      val = evaljson(params, data).source;
    }

    let newVal = iso3166.country(val).name;

    if (!newVal) {
      if (params.error) {
        objectPath.set(data, params.error, `Unable to convert country: '${val}' is not a valid ISO 3166 value.`);
      }
    } else {
      if (params.target) {
        objectPath.set(data, params.target, newVal);
      } else {
        data = newVal;
      }
    }
  } catch (e) {
    throw(new Error('Unable to convert country from ISO 3166 \'' + params.source + '\': ' +
      e));
  }

  return data;
}

{'fraction_non_alphanumeric': 0.15251487290427257, 'fraction_numerical': 0.022714981070849107, 'mean_word_length': 2.7755102040816326, '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': '6400457', 'n_tokens_mistral': 618, 'n_tokens_neox': 591, 'n_words': 149}