<commit_before>package com.penrillian.longstringloader;

import android.support.annotation.NonNull;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class LongStringUtils
{
	@NonNull
	public static List<String> getSplitString(String stringToSplit, int stringSplitLength)
	{
		/*
			length to split string needs to be at least as long as the longest series of non-whitespace in the string.
			E.G. if the following is the longest series of non-whitespace in the string
				"licences:"
			then stringSplitLength needs to be at least 9 (8 letters plus a colon)
		 */
		stringSplitLength = Math.max(getLengthOfLongestWord(stringToSplit), stringSplitLength);

		List<String> splitString = new ArrayList<>();

		Pattern p = Pattern.compile("\\G\\s*(.{1,"+ stringSplitLength +"})(?=\\s|$)", Pattern.DOTALL);
		Matcher m2 = p.matcher(stringToSplit);
		while (m2.find())
		{
			splitString.add(m2.group(1));
		}
		return splitString;
	}

	public static int getLengthOfLongestWord(String stringToSplit)
	{
		int longestWordLength = 0;
		Matcher m = Pattern.compile("\\s*(\\S+)", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE).matcher(stringToSplit);
		while(m.find())
		{
			longestWordLength = Math.max(longestWordLength, m.group(1).length());
		}
		return  longestWordLength;
	}
}<commit_msg>Refactor<commit_after>package com.penrillian.longstringloader;

import android.support.annotation.NonNull;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class LongStringUtils
{
	@NonNull
	public static List<String> getSplitString(String stringToSplit, int stringSplitLength)
	{
		/*
			length to split string needs to be at least as long as the longest series of non-whitespace in the string.
			E.G. if the following is the longest series of non-whitespace in the string
				"licences:"
			then stringSplitLength needs to be at least 9 (8 letters plus a colon)
		 */
		stringSplitLength = Math.max(getLengthOfLongestWord(stringToSplit), stringSplitLength);

		List<String> splitString = new ArrayList<>();

		Pattern p = Pattern.compile("\\G\\s*(.{1,"+ stringSplitLength +"})(?=\\s|$)", Pattern.DOTALL);
		Matcher m2 = p.matcher(stringToSplit);
		while (m2.find())
		{
			splitString.add(m2.group(1));
		}
		return splitString;
	}

	public static int getLengthOfLongestWord(String string)
	{
		int longestWordLength = 0;
		Matcher m = Pattern.compile("\\s*(\\S+)", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE).matcher(string);
		while(m.find())
		{
			longestWordLength = Math.max(longestWordLength, m.group(1).length());
		}
		return  longestWordLength;
	}
}
{'fraction_non_alphanumeric': 0.12161661104931405, 'fraction_numerical': 0.006674082313681869, 'mean_word_length': 4.540041067761807, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2568175', 'n_tokens_mistral': 934, 'n_tokens_neox': 864, 'n_words': 220}