<commit_before>module Chronic
  class Repeater < Tag #:nodoc:
    def self.scan(tokens, options)
      # for each token
      tokens.each_index do |i|
        if t = scan_for_season_names(tokens[i]) then tokens[i].tag(t); next end
        if t = scan_for_month_names(tokens[i]) then tokens[i].tag(t); next end
        if t = scan_for_day_names(tokens[i]) then tokens[i].tag(t); next end
        if t = scan_for_day_portions(tokens[i]) then tokens[i].tag(t); next end
        if t = scan_for_times(tokens[i]) then tokens[i].tag(t); next end
        if t = scan_for_units(tokens[i]) then tokens[i].tag(t); next end
      end
    end

    def self.scan_for_season_names(token)
      scan_for token, RepeaterSeasonName,
      {
        /^springs?$/ => :spring,
        /^summers?$/ => :summer,
        /^(autumn)|(fall)s?$/ => :autumn,
        /^winters?$/ => :winter
      }
    end

    def self.scan_for_month_names(token)
      scan_for token, RepeaterMonthName,
      {
        /^jan\.?(uary)?$/ => :january,
        /^feb\.?(ruary)?$/ => :february,
        /^mar\.?(ch)?$/ => :march,
        /^apr\.?(il)?$/ => :april,
        /^may$/ => :may,
        /^jun\.?e?$/ => :june,
        /^jul\.?y?$/ => :july,
        /^aug\.?(ust)?$/ => :august,
        /^sep\.?(t\.?|tember)?$/ => :september,
        /^oct\.?(ober)?$/ => :october,
        /^nov\.?(ember)?$/ => :november,
        /^dec\.?(ember)?$/ => :december
      }
    end

    def self.scan_for_day_names(token)
      scan_for token, RepeaterDayName,
      {
        /^m[ou]n(day)?$/ => :monday,
        /^t(ue|eu|oo|u|)s(day)?$/ => :tuesday,
        /^tue$/ => :tuesday,
        /^we(dnes|nds|nns)day$/ => :wednesday,
        /^wed$/ => :wednesday,
        /^th(urs|ers)day$/ => :thursday,
        /^thu(rs)?$/ => :thursday,
        /^fr[iy](day)?$/ => :friday,
        /^sat(t?[ue]rday)?$/ => :saturday,
        /^su[nm](day)?$/ => :sunday
      }
    end

    def self.scan_for_day_portions(token)
      scan_for token, RepeaterDayPortion,
      {
        /^ams?$/ => :am,
        /^pms?$/ => :pm,
        /^mornings?$/ => :morning,
        /^afternoons?$/ => :afternoon,
        /^evenings?$/ => :evening,
        /^(night|nite)s?$/ => :night
      }
    end

    def self.scan_for_times(token)
      if token.word =~ /^\d{1,2}(:?\d{2})?([\.:]?\d{2})?$/
        return Chronic::RepeaterTime.new(token.word)
      end
      return nil
    end

    def self.scan_for_units(token)
      {
        /^years?$/ => :year,
        /^seasons?$/ => :season,
        /^months?$/ => :month,
        /^fortnights?$/ => :fortnight,
        /^weeks?$/ => :week,
        /^weekends?$/ => :weekend,
        /^(week|business)days?$/ => :weekday,
        /^days?$/ => :day,
        /^hours?$/ => :hour,
        /^minutes?$/ => :minute,
        /^seconds?$/ => :second
      }.each do |item, symbol|
        if item =~ token.word
          klass_name = 'Repeater' + symbol.to_s.capitalize
          klass = Chronic.const_get(klass_name)
          return klass.new(symbol)
        end
      end
      return nil
    end

    def <=>(other)
      width <=> other.width
    end

    # returns the width (in seconds or months) of this repeatable.
    def width
      raise("Repeatable#width must be overridden in subclasses")
    end

    # returns the next occurance of this repeatable.
    def next(pointer)
      !@now.nil? || raise("Start point must be set before calling #next")
      [:future, :none, :past].include?(pointer) || raise("First argument 'pointer' must be one of :past or :future")
      #raise("Repeatable#next must be overridden in subclasses")
    end

    def this(pointer)
      !@now.nil? || raise("Start point must be set before calling #this")
      [:future, :past, :none].include?(pointer) || raise("First argument 'pointer' must be one of :past, :future, :none")
    end

    def to_s
      'repeater'
    end
  end
end<commit_msg>these should never raise as a prior check is done against context<commit_after>module Chronic
  class Repeater < Tag #:nodoc:
    def self.scan(tokens, options)
      # for each token
      tokens.each_index do |i|
        if t = scan_for_season_names(tokens[i]) then tokens[i].tag(t); next end
        if t = scan_for_month_names(tokens[i]) then tokens[i].tag(t); next end
        if t = scan_for_day_names(tokens[i]) then tokens[i].tag(t); next end
        if t = scan_for_day_portions(tokens[i]) then tokens[i].tag(t); next end
        if t = scan_for_times(tokens[i]) then tokens[i].tag(t); next end
        if t = scan_for_units(tokens[i]) then tokens[i].tag(t); next end
      end
    end

    def self.scan_for_season_names(token)
      scan_for token, RepeaterSeasonName,
      {
        /^springs?$/ => :spring,
        /^summers?$/ => :summer,
        /^(autumn)|(fall)s?$/ => :autumn,
        /^winters?$/ => :winter
      }
    end

    def self.scan_for_month_names(token)
      scan_for token, RepeaterMonthName,
      {
        /^jan\.?(uary)?$/ => :january,
        /^feb\.?(ruary)?$/ => :february,
        /^mar\.?(ch)?$/ => :march,
        /^apr\.?(il)?$/ => :april,
        /^may$/ => :may,
        /^jun\.?e?$/ => :june,
        /^jul\.?y?$/ => :july,
        /^aug\.?(ust)?$/ => :august,
        /^sep\.?(t\.?|tember)?$/ => :september,
        /^oct\.?(ober)?$/ => :october,
        /^nov\.?(ember)?$/ => :november,
        /^dec\.?(ember)?$/ => :december
      }
    end

    def self.scan_for_day_names(token)
      scan_for token, RepeaterDayName,
      {
        /^m[ou]n(day)?$/ => :monday,
        /^t(ue|eu|oo|u|)s(day)?$/ => :tuesday,
        /^tue$/ => :tuesday,
        /^we(dnes|nds|nns)day$/ => :wednesday,
        /^wed$/ => :wednesday,
        /^th(urs|ers)day$/ => :thursday,
        /^thu(rs)?$/ => :thursday,
        /^fr[iy](day)?$/ => :friday,
        /^sat(t?[ue]rday)?$/ => :saturday,
        /^su[nm](day)?$/ => :sunday
      }
    end

    def self.scan_for_day_portions(token)
      scan_for token, RepeaterDayPortion,
      {
        /^ams?$/ => :am,
        /^pms?$/ => :pm,
        /^mornings?$/ => :morning,
        /^afternoons?$/ => :afternoon,
        /^evenings?$/ => :evening,
        /^(night|nite)s?$/ => :night
      }
    end

    def self.scan_for_times(token)
      if token.word =~ /^\d{1,2}(:?\d{2})?([\.:]?\d{2})?$/
        return Chronic::RepeaterTime.new(token.word)
      end
      return nil
    end

    def self.scan_for_units(token)
      {
        /^years?$/ => :year,
        /^seasons?$/ => :season,
        /^months?$/ => :month,
        /^fortnights?$/ => :fortnight,
        /^weeks?$/ => :week,
        /^weekends?$/ => :weekend,
        /^(week|business)days?$/ => :weekday,
        /^days?$/ => :day,
        /^hours?$/ => :hour,
        /^minutes?$/ => :minute,
        /^seconds?$/ => :second
      }.each do |item, symbol|
        if item =~ token.word
          klass_name = 'Repeater' + symbol.to_s.capitalize
          klass = Chronic.const_get(klass_name)
          return klass.new(symbol)
        end
      end
      return nil
    end

    def <=>(other)
      width <=> other.width
    end

    # returns the width (in seconds or months) of this repeatable.
    def width
      raise("Repeatable#width must be overridden in subclasses")
    end

    # returns the next occurance of this repeatable.
    def next(pointer)
      !@now.nil? || raise("Start point must be set before calling #next")
    end

    def this(pointer)
      !@now.nil? || raise("Start point must be set before calling #this")
    end

    def to_s
      'repeater'
    end
  end
end
{'fraction_non_alphanumeric': 0.19207317073170732, 'fraction_numerical': 0.0010604453870625664, 'mean_word_length': 2.0521844660194173, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 93, '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': '2190926', 'n_tokens_mistral': 2901, 'n_tokens_neox': 2742, 'n_words': 566}