<commit_before>var spdx = require('spdx');

var valid = spdx.valid.bind(spdx);

var transforms = [
  function(argument) {
    return argument.toUpperCase();
  },
  function(argument) {
    return argument.trim();
  },
  function(argument) {
    return argument.replace(/\s+/g, '');
  },
  function(argument) {
    return argument.replace(/\s*(\d)/, '-$1');
  },
  function(argument) {
    return argument.replace(/\s*(\d)/, '-$1');
  },
  function(argument) {
    return argument.replace(/\s*V\s*(\d)/, '-$1');
  },
  function(argument) {
    return argument
      .replace(/\s*V\s*(\d)/, '-$1')
      .replace(/(\d)$/, '$1.0');
  }
];

var lastResorts = [
  ['APACHE', 'Apache-2.0'],
  ['AFFERO', 'AGPL-3.0'],
  ['WTF', 'WTFPL'],
  ['GPL', 'GPL-3.0'],
  ['MIT', 'MIT'],
  ['Affero', 'AGPL-3.0'],
  ['AGPL', 'AGPL-3.0'],
  ['ZLIB', 'Zlib'],
  ['3-CLAUSE', 'BSD-3-Clause'],
  ['2-CLAUSE', 'BSD-2-Clause'],
  ['3 CLAUSE', 'BSD-3-Clause'],
  ['2 CLAUSE', 'BSD-2-Clause'],
  ['UNLI', 'Unlicense'],
  ['FUCK', 'WTFPL']
];

var SUBSTRING = 0;
var IDENTIFER = 1;

module.exports = function(identifier) {
  var i;

  for (i = 0; i < transforms.length; i++) {
    var transformed = transforms[i](identifier);
    if (valid(transformed)) {
      return transformed;
    }
  }

  var upperCased = identifier.toUpperCase();
  for (i = 0; i < lastResorts.length; i++) {
    var lastResort = lastResorts[i];
    if (upperCased.indexOf(lastResort[SUBSTRING]) > -1) {
      return lastResort[IDENTIFER];
    }<commit_msg>add last-resort suggestion for "X11"<commit_after>var spdx = require('spdx');

var valid = spdx.valid.bind(spdx);

var transforms = [
  function(argument) {
    return argument.toUpperCase();
  },
  function(argument) {
    return argument.trim();
  },
  function(argument) {
    return argument.replace(/\s+/g, '');
  },
  function(argument) {
    return argument.replace(/\s*(\d)/, '-$1');
  },
  function(argument) {
    return argument.replace(/\s*(\d)/, '-$1');
  },
  function(argument) {
    return argument.replace(/\s*V\s*(\d)/, '-$1');
  },
  function(argument) {
    return argument
      .replace(/\s*V\s*(\d)/, '-$1')
      .replace(/(\d)$/, '$1.0');
  }
];

var lastResorts = [
  ['APACHE', 'Apache-2.0'],
  ['AFFERO', 'AGPL-3.0'],
  ['WTF', 'WTFPL'],
  ['GPL', 'GPL-3.0'],
  ['MIT', 'MIT'],
  ['Affero', 'AGPL-3.0'],
  ['AGPL', 'AGPL-3.0'],
  ['ZLIB', 'Zlib'],
  ['3-CLAUSE', 'BSD-3-Clause'],
  ['2-CLAUSE', 'BSD-2-Clause'],
  ['3 CLAUSE', 'BSD-3-Clause'],
  ['2 CLAUSE', 'BSD-2-Clause'],
  ['UNLI', 'Unlicense'],
  ['FUCK', 'WTFPL'],
  ['X11', 'X11']
];

var SUBSTRING = 0;
var IDENTIFER = 1;

module.exports = function(identifier) {
  var i;

  for (i = 0; i < transforms.length; i++) {
    var transformed = transforms[i](identifier);
    if (valid(transformed)) {
      return transformed;
    }
  }

  var upperCased = identifier.toUpperCase();
  for (i = 0; i < lastResorts.length; i++) {
    var lastResort = lastResorts[i];
    if (upperCased.indexOf(lastResort[SUBSTRING]) > -1) {
      return lastResort[IDENTIFER];
    }
{'fraction_non_alphanumeric': 0.23697148475909538, 'fraction_numerical': 0.02097672894133071, 'mean_word_length': 3.1467391304347827, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4516682', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1203, 'n_words': 222}