<commit_before>package com.jwetherell.algorithms.strings;

import java.util.ArrayList;
import java.util.List;

/**
 * This class contains methods for getting informations about text.
 *
 * @author <NAME> <<EMAIL>>
 */
public class StringInformations {

    /**
     * This function implements KMP algorithm for finding length of maximal prefix-suffix for each prefix of the string.
     * Prefix-suffix of string S is a substring which occurs at the beginning and at the end of S.
     *
     * Time complexity: O(n)
     *
     * https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm
     *
     * @param text Text
     * @return maximal length of prefix-suffix for each prefix of the string text
     */
    public static List<Integer> getPrefSufTable(String text) {
        List<Integer> prefSufTable = new ArrayList<>();
        if(text.length() == 0) return prefSufTable;
        prefSufTable.add(0);
        for(int i = 1; i<text.length(); i++) {
            int sizeOfPrefSuf = prefSufTable.get(i-1);
            while(sizeOfPrefSuf > 0 && text.charAt(i) != text.charAt(sizeOfPrefSuf)) {
                sizeOfPrefSuf = prefSufTable.get(sizeOfPrefSuf-1); // because string is 0-indexed
            }
            // if characters at this positions are different then sizeOfPrefSuf is equal to zero,
            // so there is no proper prefix-suffix
            if(text.charAt(i) == text.charAt(sizeOfPrefSuf)) {
                prefSufTable.add(sizeOfPrefSuf+1);
            }
            else {
                prefSufTable.add(0);
            }
        }
        return prefSufTable;
    }
}<commit_msg>Removed diamon operator<commit_after>package com.jwetherell.algorithms.strings;

import java.util.ArrayList;
import java.util.List;

/**
 * This class contains methods for getting informations about text.
 *
 * @author <NAME> <<EMAIL>>
 */
public class StringInformations {

    /**
     * This function implements KMP algorithm for finding length of maximal prefix-suffix for each prefix of the string.
     * Prefix-suffix of string S is a substring which occurs at the beginning and at the end of S.
     *
     * Time complexity: O(n)
     *
     * https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm
     *
     * @param text Text
     * @return maximal length of prefix-suffix for each prefix of the string text
     */
    public static List<Integer> getPrefSufTable(String text) {
        List<Integer> prefSufTable = new ArrayList<Integer>();
        if(text.length() == 0) return prefSufTable;
        prefSufTable.add(0);
        for(int i = 1; i<text.length(); i++) {
            int sizeOfPrefSuf = prefSufTable.get(i-1);
            while(sizeOfPrefSuf > 0 && text.charAt(i) != text.charAt(sizeOfPrefSuf)) {
                sizeOfPrefSuf = prefSufTable.get(sizeOfPrefSuf-1); // because string is 0-indexed
            }
            // if characters at this positions are different then sizeOfPrefSuf is equal to zero,
            // so there is no proper prefix-suffix
            if(text.charAt(i) == text.charAt(sizeOfPrefSuf)) {
                prefSufTable.add(sizeOfPrefSuf+1);
            }
            else {
                prefSufTable.add(0);
            }
        }
        return prefSufTable;
    }
}
{'fraction_non_alphanumeric': 0.10173621687480963, 'fraction_numerical': 0.011574779165397502, 'mean_word_length': 2.347604485219164, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 2, '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': '2559439', 'n_tokens_mistral': 1015, 'n_tokens_neox': 987, 'n_words': 268}