<commit_before>package util;

import complex.Complex;

public class ComplexValueParser {

	public static Complex parseFromString(String value) {

		if (ComplexValueParser.countOccurrenceInString(value, "+")
				+ ComplexValueParser.countOccurrenceInString(value, "-") > 2) {

			return null;

		}

		String splitter = "+";
		double real = Double.NaN;
		double imaginary = Double.NaN;
		boolean realIsPositive = true;
		boolean imaginaryIsPositive = true;

		if (value.subSequence(0, 1).toString().contains("-")) {

			realIsPositive = false;

		}

		if (value.substring(1).contains("-")) {

			splitter = "-";
			imaginaryIsPositive = false;

		}

		String[] tokens = value.substring(1).replaceAll(",", ".").split("[" + splitter + "]");

		for (String token : tokens) {

			try {

				if (token.contains("i") && token.indexOf("i") == token.length() - 1) {

					String parsedToken = (String) token.subSequence(0, token.length() - 1);
					imaginary = Double.parseDouble(parsedToken);

				} else {

					real = Double.parseDouble(token);

				}

			} catch (NumberFormatException exception) {

				return null;

			}

		}

		if (!realIsPositive) {

			real = -real;

		}

		if (!imaginaryIsPositive) {

			imaginary = -imaginary;

		}

		return new Complex(real, imaginary);

	}

	public static int countOccurrenceInString(String haystack, String needle) {

		int lastIndex = 0;
		int count = 0;

		while (lastIndex != -1) {

			lastIndex = haystack.indexOf(needle, lastIndex);

			if (lastIndex != -1) {

				count++;
				lastIndex += needle.length();

			}
		}

		return count;

	}

}<commit_msg>Updated complex value parser<commit_after>package util;

import complex.Complex;

public class ComplexValueParser {

	public static Complex parseFromString(String value) {

		if (ComplexValueParser.countOccurrenceInString(value, "+")
				+ ComplexValueParser.countOccurrenceInString(value, "-") > 2) {
			return null;
		}

		if (value.equals("")) {
			return null;
		}

		String splitter = "+";
		double real = Double.NaN;
		double imaginary = Double.NaN;
		boolean realIsPositive = true;
		boolean imaginaryIsPositive = true;

		if (value.subSequence(0, 1).toString().contains("-")) {
			realIsPositive = false;
		}

		if (value.substring(1).contains("-")) {
			splitter = "-";
			imaginaryIsPositive = false;
		}

		String[] tokens = value.substring(1).replaceAll(",", ".").split("[" + splitter + "]");

		for (String token : tokens) {
			try {
				if (token.contains("i") && token.indexOf("i") == token.length() - 1) {
					String parsedToken = (String) token.subSequence(0, token.length() - 1);
					imaginary = Double.parseDouble(parsedToken);
				} else {
					real = Double.parseDouble(token);
				}
			} catch (NumberFormatException exception) {
				return null;
			}
		}

		if (!realIsPositive) {
			real = -real;
		}

		if (!imaginaryIsPositive) {
			imaginary = -imaginary;
		}

		return new Complex(real, imaginary);

	}

	public static int countOccurrenceInString(String haystack, String needle) {

		int lastIndex = 0;
		int count = 0;

		while (lastIndex != -1) {

			lastIndex = haystack.indexOf(needle, lastIndex);
			if (lastIndex != -1) {
				count++;
				lastIndex += needle.length();
			}

		}

		return count;

	}

}
{'fraction_non_alphanumeric': 0.14647713226205192, 'fraction_numerical': 0.007416563658838072, 'mean_word_length': 3.2536136662286466, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4526825', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1020, 'n_words': 231}