<commit_before><?php

/**
 * UTF-8 aware alternative to str_ireplace.
 *
 * Case-insensitive version of str_replace
 * This function is not fast and gets slower if $search/$replace is array.
 * It assumes that the lower and uppercase versions of a UTF-8 character will
 * have the same length in bytes which is currently true given the hash table
 * to strtolower.
 *
 * @package php-utf8
 * @subpackage functions
 * @uses utf8_strtolower
 * @see http://www.php.net/str_ireplace
 * @param string $search
 * @param string $replace
 * @param string $str
 * @param int $count
 * @return string
 */
function utf8_ireplace($search, $replace, $str, $count = null)
{
	if (!is_array($search))
	{
		$slen = strlen($search);

		if ($slen == 0)
			return $str;

		$lendif = strlen($replace) - strlen($search);
		$search = utf8_strtolower($search);

		$search = preg_quote($search,'/');
		$lstr = utf8_strtolower($str);
		$i = 0;
		$matched = 0;

		while (preg_match('/(.*)'.$search.'/Us', $lstr, $matches))
		{
			if ($i === $count)
				break;

			$mlen = strlen($matches[0]);
			$lstr = substr($lstr, $mlen);
			$str = substr_replace($str, $replace, $matched + strlen($matches[1]), $slen);
			$matched += $mlen + $lendif;
			$i++;
		}<commit_msg>Spacing.<commit_after><?php

/**
 * UTF-8 aware alternative to str_ireplace.
 *
 * Case-insensitive version of str_replace
 * This function is not fast and gets slower if $search/$replace is array.
 * It assumes that the lower and uppercase versions of a UTF-8 character will
 * have the same length in bytes which is currently true given the hash table
 * to strtolower.
 *
 * @package php-utf8
 * @subpackage functions
 * @uses utf8_strtolower
 * @see http://www.php.net/str_ireplace
 * @param string $search
 * @param string $replace
 * @param string $str
 * @param int $count
 * @return string
 */
function utf8_ireplace($search, $replace, $str, $count = null)
{
	if (!is_array($search))
	{
		$slen = strlen($search);

		if ($slen == 0)
			return $str;

		$lendif = strlen($replace) - strlen($search);
		$search = utf8_strtolower($search);

		$search = preg_quote($search, '/');
		$lstr = utf8_strtolower($str);
		$i = 0;
		$matched = 0;

		while (preg_match('/(.*)'.$search.'/Us', $lstr, $matches))
		{
			if ($i === $count)
				break;

			$mlen = strlen($matches[0]);
			$lstr = substr($lstr, $mlen);
			$str = substr_replace($str, $replace, $matched + strlen($matches[1]), $slen);
			$matched += $mlen + $lendif;
			$i++;
		}
{'fraction_non_alphanumeric': 0.163290113452188, 'fraction_numerical': 0.009724473257698542, 'mean_word_length': 3.7572254335260116, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7118966', 'n_tokens_mistral': 924, 'n_tokens_neox': 848, 'n_words': 248}