<commit_before>/*#ifndef(UMD)*/
"use strict";
/*global _gpfAssert*/ // Assertion method
/*global _gpfExtend*/ // gpf.extend
/*global _gpfPathDecompose*/ // Normalize path and returns an array of parts
/*#endif*/

// Split the part to be processed in _GpfPathMatcher#_matchName
function _gpfPatternPartSplit (part) {
    return part.split("*");
}

/**
 * @param {String} pattern
 *
 * @class _GpfLikeContext
 * @constructor
 */
function _GpfPathMatcher (pattern) {
    /*jshint validthis:true*/
/*#ifdef(DEBUG)*/
    this._dbgSource = pattern;
/*#endif*/

    if ("!" === pattern.charAt(0)) {
        this.negative = true;
        pattern = pattern.substr(1);
    }

    /**
     * if any use of "**", split the pattern in two:
     * - the before part: start
     * - the after part: end
     * (otherwise, it is only the before part)
     */
    var pos = pattern.indexOf("**");
    if (-1 === pos) {
        this.start = pattern
            .split("/")
            .map(_gpfPatternPartSplit);
    } else {
        if (0 < pos) {
            _gpfAssert(pattern.charAt(pos - 1) === "/", "** must be preceded by /");
            this.start = pattern
                .substr(0, pos - 1) // skip /
                .split("/")
                .map(_gpfPatternPartSplit);
        }
        if (pos < pattern.length - 2) {
            _gpfAssert(pattern.charAt(pos + 2) === "/", "** must be followed by /");
            this.end = pattern
                .substr(pos + 3) // skip /
                .split("/")
                .map(_gpfPatternPartSplit)
                .reverse();
        }
    }
}

/**
 * Convert - if necessary - the pattern parameter
 *
 * @param {_GpfPathMatcher|String} pattern
 * @return {_GpfPathMatcher}
 */
function _gpfPathMatchCompilePattern (pattern) {
    if (pattern instanceof _GpfPathMatcher) {
        return pattern;
    } else {
        return new _GpfPathMatcher(pattern);
    }
}

/**
 * Convert - if necessary - the pattern parameter
 *
 * @param {Array|String} pattern
 * @return {_GpfPathMatcher[]}
 */
function _gpfPathMatchCompilePatterns (pattern) {
    if (pattern instanceof Array) {
        return pattern.map(_gpfPathMatchCompilePattern);
    } else {
        return [_gpfPathMatchCompilePattern(pattern)];
    }
}

/**
 * Match a path item
 *
 * @param pathMatcher
 * @this An object containing
 * - {String[]} parts the path being tested split in parts
 * - {Boolean} [result=undefined] result the result<commit_msg>ESLint fixes<commit_after>/*#ifndef(UMD)*/
"use strict";
/*global _gpfAssert*/ // Assertion method
/*global _gpfExtend*/ // gpf.extend
/*global _gpfPathDecompose*/ // Normalize path and returns an array of parts
/*#endif*/

// Split the part to be processed in _GpfPathMatcher#_matchName
function _gpfPatternPartSplit (part) {
    return part.split("*");
}

/**
 * @param {String} pattern
 *
 * @class _GpfLikeContext
 * @constructor
 */
function _GpfPathMatcher (pattern) {
    /*jshint validthis:true*/
/*#ifdef(DEBUG)*/
    this._dbgSource = pattern;
/*#endif*/

    if ("!" === pattern.charAt(0)) {
        this.negative = true;
        pattern = pattern.substr(1);
    }

    /**
     * if any use of "**", split the pattern in two:
     * - the before part: start
     * - the after part: end
     * (otherwise, it is only the before part)
     */
    var pos = pattern.indexOf("**");
    if (-1 === pos) {
        this.start = pattern
            .split("/")
            .map(_gpfPatternPartSplit);
    } else {
        if (0 < pos) {
            _gpfAssert(pattern.charAt(pos - 1) === "/", "** must be preceded by /");
            this.start = pattern
                .substr(0, pos - 1) // skip /
                .split("/")
                .map(_gpfPatternPartSplit);
        }
        if (pos < pattern.length - 2) {
            _gpfAssert(pattern.charAt(pos + 2) === "/", "** must be followed by /");
            this.end = pattern
                .substr(pos + 3) // skip /
                .split("/")
                .map(_gpfPatternPartSplit)
                .reverse();
        }
    }
}

/**
 * Convert - if necessary - the pattern parameter
 *
 * @param {_GpfPathMatcher|String} pattern
 * @return {_GpfPathMatcher}
 */
function _gpfPathMatchCompilePattern (pattern) {
    if (pattern instanceof _GpfPathMatcher) {
        return pattern;
    }
    return new _GpfPathMatcher(pattern);
}

/**
 * Convert - if necessary - the pattern parameter
 *
 * @param {Array|String} pattern
 * @return {_GpfPathMatcher[]}
 */
function _gpfPathMatchCompilePatterns (pattern) {
    if (pattern instanceof Array) {
        return pattern.map(_gpfPathMatchCompilePattern);
    }
    return [_gpfPathMatchCompilePattern(pattern)];
}

/**
 * Match a path item
 *
 * @param pathMatcher
 * @this An object containing
 * - {String[]} parts the path being tested split in parts
 * - {Boolean} [result=undefined] result the result
{'fraction_non_alphanumeric': 0.14165813715455475, 'fraction_numerical': 0.0040941658137154556, 'mean_word_length': 2.240053050397878, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '1958737', 'n_tokens_mistral': 1515, 'n_tokens_neox': 1469, 'n_words': 390}