<commit_before>'use strict';

var _ = require('lodash');
var pilots = require('../../generated/pilots');

var sortedPilots = pilots.sort(function (a, b) {
    if (a.skill < b.skill) {
        return -1;
    }
    if (a.skill > b.skill) {
        return 1;
    }

    // skills must be equal
    if (a.name < b.name) {
        return -1;
    }
    if (a.name > b.name) {
        return 1;
    }
    // skills and names must be equal
    return 0;
});

// TODO: filter out pilots from large ships

// key upgrades by type
var rebelPilots = _.filter(sortedPilots, function (pilot) {
    return pilot.faction === 'Rebel Alliance' || pilot.faction === 'Resistance';
});
var pilotsWithAbilities = _.filter(rebelPilots, function (pilot) {
    return pilot.text;
});

module.exports = {
    allRebels: rebelPilots,
    pilotsWithAbilities: pilotsWithAbilities
};
<commit_msg>filter out huge ship pilots from abilities list<commit_after>'use strict';

var _ = require('lodash');
var pilots = require('../../generated/pilots');
var shipsData = require('../../generated/ships');

var getShipDataByName = function (shipName) {
    return _.find(shipsData, function (shipData) {
        return shipData.name === shipName;
    });
};

var sortedPilots = pilots.sort(function (a, b) {
    if (a.skill < b.skill) {
        return -1;
    }
    if (a.skill > b.skill) {
        return 1;
    }

    // skills must be equal
    if (a.name < b.name) {
        return -1;
    }
    if (a.name > b.name) {
        return 1;
    }
    // skills and names must be equal
    return 0;
});

// TODO: filter out pilots from large ships

// Filter to only include rebel pilots
var rebelPilots = _.filter(sortedPilots, function (pilot) {
    return pilot.faction === 'Rebel Alliance' || pilot.faction === 'Resistance';
});
// filter to only include pilots with abilities (e.g. get rid of generics)
var pilotsWithAbilities = _.filter(rebelPilots, function (pilot) {
    return pilot.text;
});
// filter to rmeove pilots for huge ships
var nonHugePilots = _.filter(pilotsWithAbilities, function (pilot) {
    var shipName = pilot.ship;
    var matchingShip = getShipDataByName(shipName);
    if (matchingShip.size === 'huge') {
        return false;
    }
    return true;
});

// key upgrades by type
module.exports = {
    allRebels: rebelPilots,
    pilotsWithAbilities: nonHugePilots
};

{'fraction_non_alphanumeric': 0.1355357899195256, 'fraction_numerical': 0.004235493434985175, 'mean_word_length': 2.7373417721518987, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '7296782', 'n_tokens_mistral': 782, 'n_tokens_neox': 781, 'n_words': 220}