<commit_before>function similar_text (first, second) {
    /*
     * This is a direct port from PHP source code with a few modifications. May be buggy.
     * This function still needs to be checked and unit tested.
     * Other goals are to switch from recursive to iterative approach
     *
     * Original by: <NAME>
     */
    var pos1 = 0, pos2 = 0, max = 0,
        firstLength = first.length, secondLength = second.length,
        p, q, l, sum;
    
    max = 0;
    
    for (p = 0; p < firstLength; p++) {
        for(q = 0; q < secondLength; q++) {
            for (l = 0; (p + l < firstLength) && (q + l < secondLength) && (first.charAt(p + l) === second.charAt(q + l)); l++);
            if (l > max) {<commit_msg>Supporting cases where either first or second param is null or undefined<commit_after>function similar_text (first, second) {
    // http://kevin.vanzonneveld.net
    // +   original by: <NAME> (http://blog.kukawski.pl)
    // *     example 1: similar_text('Hello World!', 'Hello phpjs!');
    // *     returns 1: 7
    // *     example 2: similar_text('Hello World!', null);
    // *     returns 2: 0
    
    if (first === null || second === null || typeof first === "undefined" || typeof second === "undefined") {
        return 0;
    }
    
    first += ''; second += '';
    
    var pos1 = 0, pos2 = 0, max = 0,
        firstLength = first.length, secondLength = second.length,
        p, q, l, sum;
    
    max = 0;
    
    for (p = 0; p < firstLength; p++) {
        for(q = 0; q < secondLength; q++) {
            for (l = 0; (p + l < firstLength) && (q + l < secondLength) && (first.charAt(p + l) === second.charAt(q + l)); l++);
            if (l > max) {
{'fraction_non_alphanumeric': 0.15625, 'fraction_numerical': 0.01474056603773585, 'mean_word_length': 2.0910746812386156, 'pattern_counts': {'":': 0, '<': 13, '<?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': '4918684', 'n_tokens_mistral': 570, 'n_tokens_neox': 544, 'n_words': 185}