<commit_before>'use strict';

const moment = require('moment');
const find = require('lodash/find');
const get = require('lodash/get');
const mapValues = require('lodash/mapValues');
const semver = require('semver');
const normalizeValue = require('normalize-value');

const log = logger.child({ module: 'evaluate/maintenance' });

/**
 * Evaluates the releases frequency.
 *
 * @param {Object} collected - The collected information.
 *
 * @returns {Number} The releases frequency evaluation (from 0 to 1).
 */
function evaluateReleasesFrequency(collected) {
    const releases = collected.metadata.releases;

    if (!releases) {
        return 0;
    }

    const range30 = find(releases, (range) => moment.utc(range.to).diff(range.from, 'd') === 30);
    const range180 = find(releases, (range) => moment.utc(range.to).diff(range.from, 'd') === 180);
    const range365 = find(releases, (range) => moment.utc(range.to).diff(range.from, 'd') === 365);
    const range730 = find(releases, (range) => moment.utc(range.to).diff(range.from, 'd') === 730);

    if (!range30 || !range180 || !range365 || !range730) {
        throw new Error('Could not find entry in releases');
    }

    const mean30 = range30.count / (30 / 90);
    const mean180 = range180.count / (180 / 90);
    const mean365 = range365.count / (365 / 90);
    const mean730 = range365.count / (730 / 90);

    const quarterMean = (mean30 * 0.25) +
                        (mean180 * 0.45) +
                        (mean365 * 0.2) +
                        (mean730 * 0.1);

    return normalizeValue(quarterMean, [
        { value: 0, norm: 0 },
        { value: 0.5, norm: 0.5 },
        { value: 1, norm: 0.75 },
        { value: 2, norm: 1 },
    ]);
}

/**
 * Evaluates the commits frequency.
 *
 * @param {Object} collected - The collected information.
 *
 * @returns {Number} The commits frequency evaluation (from 0 to 1).
 */
function evaluateCommitsFrequency(collected) {
    const commits = collected.github && collected.github.commits;
<commit_msg>fix: fix typo in maintenance evaluation<commit_after>'use strict';

const moment = require('moment');
const find = require('lodash/find');
const get = require('lodash/get');
const mapValues = require('lodash/mapValues');
const semver = require('semver');
const normalizeValue = require('normalize-value');

const log = logger.child({ module: 'evaluate/maintenance' });

/**
 * Evaluates the releases frequency.
 *
 * @param {Object} collected - The collected information.
 *
 * @returns {Number} The releases frequency evaluation (from 0 to 1).
 */
function evaluateReleasesFrequency(collected) {
    const releases = collected.metadata.releases;

    if (!releases) {
        return 0;
    }

    const range30 = find(releases, (range) => moment.utc(range.to).diff(range.from, 'd') === 30);
    const range180 = find(releases, (range) => moment.utc(range.to).diff(range.from, 'd') === 180);
    const range365 = find(releases, (range) => moment.utc(range.to).diff(range.from, 'd') === 365);
    const range730 = find(releases, (range) => moment.utc(range.to).diff(range.from, 'd') === 730);

    if (!range30 || !range180 || !range365 || !range730) {
        throw new Error('Could not find entry in releases');
    }

    const mean30 = range30.count / (30 / 90);
    const mean180 = range180.count / (180 / 90);
    const mean365 = range365.count / (365 / 90);
    const mean730 = range730.count / (730 / 90);

    const quarterMean = (mean30 * 0.25) +
                        (mean180 * 0.45) +
                        (mean365 * 0.2) +
                        (mean730 * 0.1);

    return normalizeValue(quarterMean, [
        { value: 0, norm: 0 },
        { value: 0.5, norm: 0.5 },
        { value: 1, norm: 0.75 },
        { value: 2, norm: 1 },
    ]);
}

/**
 * Evaluates the commits frequency.
 *
 * @param {Object} collected - The collected information.
 *
 * @returns {Number} The commits frequency evaluation (from 0 to 1).
 */
function evaluateCommitsFrequency(collected) {
    const commits = collected.github && collected.github.commits;

{'fraction_non_alphanumeric': 0.15589818893783652, 'fraction_numerical': 0.0548213411649535, 'mean_word_length': 2.9373795761079, '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': '2630053', 'n_tokens_mistral': 1456, 'n_tokens_neox': 1221, 'n_words': 343}