<commit_before>module AtomicTV
  class FilenameParser

    class InvalidFilename < ::AtomicTV::AtomicTVError
      def initialize(filename)
        @filename = filename
      end

      attr_reader :filename

      def human_message
        "Invalid filename: #{filename} (filenames must be in the format: 'Series Name - S01E01')."
      end
    end

    FilenameFormat =  /\A(.*) - S(\d{2})E(\d{2})\.\w{3}\Z/

    def self.parse(filename)
      if filename.to_s =~ FilenameFormat
        new($1, $2.to_i(10), $3.to_i(10))
      else
        raise InvalidFilename.new(filename)
      end
    end

    attr_reader :series_name, :season_number, :episode_number

    private

    def initialize(series_name, season_number, episode_number)
      @series_name = series_name
      @season_number = season_number
      @episode_number = episode_number
    end

  end
end<commit_msg>be a little bit looser with filenames to accept<commit_after>module AtomicTV
  class FilenameParser

    class InvalidFilename < ::AtomicTV::AtomicTVError
      def initialize(filename)
        @filename = filename
      end

      attr_reader :filename

      def human_message
        "Invalid filename: #{filename} (filenames must be in the format: 'Series Name - S01E01')."
      end
    end

    FilenameFormat =  /\A(.*)(?: - |\.)S(\d{2})E(\d{2}).*\.\w{3}\Z/

    def self.parse(filename)
      if filename.to_s =~ FilenameFormat
        series_name, season_num, episode_num = $1, $2, $3
        series_name.gsub!('.', ' ')
        season_num = season_num.to_i(10)
        episode_num = episode_num.to_i(10)
        new(series_name, season_num, episode_num)
      else
        raise InvalidFilename.new(filename)
      end
    end

    attr_reader :series_name, :season_number, :episode_number

    private

    def initialize(series_name, season_number, episode_number)
      @series_name = series_name
      @season_number = season_number
      @episode_number = episode_number
    end

  end
end
{'fraction_non_alphanumeric': 0.10207175341081354, 'fraction_numerical': 0.01414855987872663, 'mean_word_length': 2.680297397769517, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '794974', 'n_tokens_mistral': 653, 'n_tokens_neox': 616, 'n_words': 146}