<commit_before>module PersonMatchStrategies
  class FirstLastDob
    def match(options = {})
      return [nil, nil] if options[:dob].blank?
      name_first_regex = Regexp.compile(Regexp.escape(options[:name_first].to_s.strip.downcase), true)
      name_last_regex = Regexp.compile(Regexp.escape(options[:name_last].to_s.strip.downcase), true)
      search_dob = cast_dob(options[:dob], options)
      found_people = Person.where({"members.dob" => search_dob, "name_first" => name_first_regex, "name_last" => name_last_regex})
      if found_people.any?
        if found_people.many?
          raise AmbiguousMatchError.new("Multiple people with same first, last, and dob: #{options[:name_first]}, #{options[:name_last]}, #{options[:dob]}")
        else
          select_authority_member(found_people.first, options)
        end
      else
        [nil, nil]
      end
    end

    def cast_dob(dob, options)
      if dob.kind_of?(Date)
        return dob
      elsif dob.kind_of?(DateTime)
        return dob
      end<commit_msg>Don't run the dob match if they don't provide dob.<commit_after>module PersonMatchStrategies
  class FirstLastDob
    def match(options = {})
      return([nil, nil]) if options[:dob].blank?
      name_first_regex = Regexp.compile(Regexp.escape(options[:name_first].to_s.strip.downcase), true)
      name_last_regex = Regexp.compile(Regexp.escape(options[:name_last].to_s.strip.downcase), true)
      search_dob = cast_dob(options[:dob], options)
      found_people = Person.where({"members.dob" => search_dob, "name_first" => name_first_regex, "name_last" => name_last_regex})
      if found_people.any?
        if found_people.many?
          raise AmbiguousMatchError.new("Multiple people with same first, last, and dob: #{options[:name_first]}, #{options[:name_last]}, #{options[:dob]}")
        else
          select_authority_member(found_people.first, options)
        end
      else
        [nil, nil]
      end
    end

    def cast_dob(dob, options)
      if dob.kind_of?(Date)
        return dob
      elsif dob.kind_of?(DateTime)
        return dob
      end
{'fraction_non_alphanumeric': 0.11845861084681256, 'fraction_numerical': 0.0, 'mean_word_length': 3.2918367346938777, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4550034', 'n_tokens_mistral': 690, 'n_tokens_neox': 691, 'n_words': 135}