<commit_before><?php  namespace App\Utils;

class Utils {

    /**
     * New line supporting cli or browser
     * @return string
     */
    public static function newLine() {
        if(php_sapi_name() == "cli") {
            return "\n";
        }

        return "<br>";
    }

    /**
     * Count the total lessons of an array of lessons & series
     * @param $array
     *
     * @return int
     */
    public static function countAllLessons($array) {
        $total = count($array['lessons']);
        foreach ($array['series'] as $serie => $episodes) {
            $total += count($episodes);
        }
        return $total;
    }

    /**
     * Counts the lessons from the array
     * @param $array
     *
     * @return int
     */
    public static function countLessons($array) {
        return count($array['lessons']);
    }

    /**
     * Counts the episodes from the array
     * @param $array
     *
     * @return int
     */
    public static function countEpisodes($array) {
        $total = 0;
        foreach ($array['series'] as $serie => $episodes) {
            $total += count($episodes);
        }
        return $total;
    }

    /**
     * Compare two arrays and returns the diff array
     * @param $onlineListArray
     * @param $localListArray
     *
     * @return array
     */
    public static function resolveFaultyLessons($onlineListArray, $localListArray) {
        $array['series'] = [];
        $array['lessons'] = [];

        foreach ($onlineListArray['series'] as $serie => $episodes) {
            if(isset($localListArray['series'][$serie])) {
                if(count($episodes) == count($localListArray['series'][$serie])) continue;

                foreach ($episodes as $episode) {
                    if(!in_array($episode, $localListArray['series'][$serie]))
                        $array['series'][$serie][] = $episode;
                }
            } else {
                $array['series'][$serie] = $episodes;
            }
        }

        $array['lessons'] = array_diff($onlineListArray['lessons'], $localListArray['lessons']);

        return $array;
    }

    /**
     * Echo's text in a nice box
     * @param $text
     */
    public static function box($text) {
        echo self::newLine();
        echo "====================================" . self::newLine();
        echo $text . self::newLine();
        echo "====================================" . self::newLine();
    }

    /**
     * Echo's a message
     * @param $text
     */
    public static function write($text) {
        echo "> " . $text . self::newLine();
    }

    /**
     * Remove specials chars that windows does not support for filenames
     * @param $name
     *
     * @return mixed
     */
    public static function parseEpisodeName($name)
    {
        return str_replace(['\'', '/', ',', ':', ';', '#', '*', '!', '$', '?', '\\', '»', '»', '<', '>'], ' ', $name);
    }

    /**
     * Echo's a message in a new line
     * @param $text
     */
    public static function writeln($text)
    {
        echo self::newLine();
        echo "> " . $text . self::newLine();
    }

}<commit_msg>Changed regex of the name of the episodes<commit_after><?php  namespace App\Utils;

class Utils {

    /**
     * New line supporting cli or browser
     * @return string
     */
    public static function newLine() {
        if(php_sapi_name() == "cli") {
            return "\n";
        }

        return "<br>";
    }

    /**
     * Count the total lessons of an array of lessons & series
     * @param $array
     *
     * @return int
     */
    public static function countAllLessons($array) {
        $total = count($array['lessons']);
        foreach ($array['series'] as $serie => $episodes) {
            $total += count($episodes);
        }
        return $total;
    }

    /**
     * Counts the lessons from the array
     * @param $array
     *
     * @return int
     */
    public static function countLessons($array) {
        return count($array['lessons']);
    }

    /**
     * Counts the episodes from the array
     * @param $array
     *
     * @return int
     */
    public static function countEpisodes($array) {
        $total = 0;
        foreach ($array['series'] as $serie => $episodes) {
            $total += count($episodes);
        }
        return $total;
    }

    /**
     * Compare two arrays and returns the diff array
     * @param $onlineListArray
     * @param $localListArray
     *
     * @return array
     */
    public static function resolveFaultyLessons($onlineListArray, $localListArray) {
        $array['series'] = [];
        $array['lessons'] = [];

        foreach ($onlineListArray['series'] as $serie => $episodes) {
            if(isset($localListArray['series'][$serie])) {
                if(count($episodes) == count($localListArray['series'][$serie])) continue;

                foreach ($episodes as $episode) {
                    if(!in_array($episode, $localListArray['series'][$serie]))
                        $array['series'][$serie][] = $episode;
                }
            } else {
                $array['series'][$serie] = $episodes;
            }
        }

        $array['lessons'] = array_diff($onlineListArray['lessons'], $localListArray['lessons']);

        return $array;
    }

    /**
     * Echo's text in a nice box
     * @param $text
     */
    public static function box($text) {
        echo self::newLine();
        echo "====================================" . self::newLine();
        echo $text . self::newLine();
        echo "====================================" . self::newLine();
    }

    /**
     * Echo's a message
     * @param $text
     */
    public static function write($text) {
        echo "> " . $text . self::newLine();
    }

    /**
     * Remove specials chars that windows does not support for filenames
     * @param $name
     *
     * @return mixed
     */
    public static function parseEpisodeName($name)
    {
        return preg_replace('/[^A-Za-z0-9\- _]/', '', $name);;
    }

    /**
     * Echo's a message in a new line
     * @param $text
     */
    public static function writeln($text)
    {
        echo self::newLine();
        echo "> " . $text . self::newLine();
    }

}
{'fraction_non_alphanumeric': 0.1743295019157088, 'fraction_numerical': 0.0006385696040868455, 'mean_word_length': 1.9071925754060324, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7086672', 'n_tokens_mistral': 1856, 'n_tokens_neox': 1792, 'n_words': 431}