<commit_before>import java.util.Scanner;

// TODO: Full explaination in comments
public class ZAlgorithm
{
	static int [] z_array;
	public static void if_pattern_in_text(String text, String pattern){
		String pattern_plus_text = new StringBuilder().append(<commit_msg>added documentation for z algorithm<commit_after>import java.util.Scanner;

/*
	Z Algorithm is a pattern matching algorithm, with the time complexity of 
	O(M + N), where M is the length of the pattern and N is the length of the 
	text. 

	It is basically used with the pattern to be found in the text added as a
	prefix to the text for something like:

	bluemix = text
	mix = pattern

	pattern plus text = mix + "$" + bluemix => mix$bluemix
	For this pattern plus text, we form a Z array, which stores how many 
	elements on a particular index matches starting from the prefix of the
	string.

	lets say for 
	
	index  = 0 1 2 3 4 5 6 7 8 9 10
	text   = m i x $ b l u e m i x
	Zvalue = 0 0 0 0 0 0 0 0 3 0 0

	if the Z value is equal to the length of the string we are trying to find
	in the pattern plus text we have found the string. 

	We always set the value of the first character to be 0, considering there is
	no prefix before it. 
	
	An important case we need to consider in this algorithm is: for a matched
	string, it is contained inside a `LR` window, now for the above example
	there is a LR window starting from m to x -> `mix` from indexes 8 to 10. 

	if the corresponding Z value in the prefix is greater than the length of the 
	string left, then we need to consider finding new Z value and form a new LR
	window. 
*/
public class ZAlgorithm
{
	static int [] z_array;
	public static void if_pattern_in_text(String text, String pattern){
		String pattern_plus_text = new StringBuilder().append(
{'fraction_non_alphanumeric': 0.047806524184476944, 'fraction_numerical': 0.015185601799775027, 'mean_word_length': 3.5267175572519083, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6785306', 'n_tokens_mistral': 554, 'n_tokens_neox': 500, 'n_words': 295}