<commit_before>function substr_count (haystack, needle, offset, length) {
    // http://kevin.vanzonneveld.net
    // +   original by: <NAME> (http://kevin.vanzonneveld.net)
    // +   bugfixed by: <NAME>
    // +   improved by: <NAME> (http://brett-zamir.me)
    // *     example 1: substr_count('<NAME>', 'e');
    // *     returns 1: 3
    // *     example 2: substr_count('<NAME>', 'K', 1);
    // *     returns 2: 0
    // *     example 3: substr_count('<NAME>', 'Z', 0, 10);
    // *     returns 3: false

    var pos = 0,
        cnt = 0;

    haystack += '';
    needle += '';
    if (isNaN(offset)) {
        offset = 0;
    }
    if (isNaN(length)) {
        length = 0;
    }
    offset--;

    while ((offset = haystack.indexOf(needle, offset + 1)) != -1) {
        if (length > 0 && (offset + needle.length) > length) {
            return false;
        }
        cnt++;
    }

    return cnt;
}
<commit_msg>Rmv unnecessary var (Thanks, Thomas!)<commit_after>function substr_count (haystack, needle, offset, length) {
    // http://kevin.vanzonneveld.net
    // +   original by: <NAME> (http://kevin.vanzonneveld.net)
    // +   bugfixed by: <NAME>
    // +   improved by: <NAME> (http://brett-zamir.me)
    // +   improved by: Thomas
    // *     example 1: substr_count('<NAME>', 'e');
    // *     returns 1: 3
    // *     example 2: substr_count('<NAME>', 'K', 1);
    // *     returns 2: 0
    // *     example 3: substr_count('<NAME>', 'Z', 0, 10);
    // *     returns 3: false

    var cnt = 0;

    haystack += '';
    needle += '';
    if (isNaN(offset)) {
        offset = 0;
    }
    if (isNaN(length)) {
        length = 0;
    }
    offset--;

    while ((offset = haystack.indexOf(needle, offset + 1)) != -1) {
        if (length > 0 && (offset + needle.length) > length) {
            return false;
        }
        cnt++;
    }

    return cnt;
}

{'fraction_non_alphanumeric': 0.17864476386036962, 'fraction_numerical': 0.018993839835728953, 'mean_word_length': 1.6231493943472408, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, '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': '3931463', 'n_tokens_mistral': 708, 'n_tokens_neox': 654, 'n_words': 155}