<commit_before>module NipPeselRegon
  module Validator
    # Base validation class with common functionality for validators.
    # Provides common public interface for validators.
    class Base

      attr_reader :number, :original_number, :options

      def initialize(number, options = {})
        # need to make input number a string because
        # whole functionality is based on strings
        @number = number.to_s
        # keep original number
        @original_number = number

        @options = options

        # normalize provided number
        normalize
      end

      # Check if number is valid.
      def valid?
        # check if number provided has proper format
        return false unless has_proper_format?
        validate
      end

      # To string conversion returns normalized number.
      def to_s
        number
      end

      private

      # method responsible for detection if number provided has proper format
      def has_proper_format?
        !number.nil? && matches_pattern?
      end

      # Method responsible for pattern matching.
      # Uses PATTERN constant from subclass.
      def matches_pattern?
        self.class::PATTERN =~ number
      end

      # Internal validation method - need to be overriden in subclasses.
      def validate
        raise NoMethodError, "No validate method defined in #{self.class}"
      end
<commit_msg>Comments update in base validator class.<commit_after>module NipPeselRegon
  module Validator
    # Base validation class with common functionality for validators.
    # Provides common public interface for validators.
    class Base

      attr_reader :number, :original_number, :options

      def initialize(number, options = {})
        # need to make input number a string because
        # whole functionality is based on strings
        @number = number.to_s
        # keep original number
        @original_number = number

        @options = options

        # normalize provided number
        normalize
      end

      # Check if number is valid.
      def valid?
        # check if number provided has proper format
        return false unless has_proper_format?
        validate
      end

      # To string conversion returns normalized number.
      def to_s
        number
      end

      private

      # Method responsible for detection if number provided has proper format.
      def has_proper_format?
        !number.nil? && matches_pattern?
      end

      # Method responsible for pattern matching.
      # Uses PATTERN constant from subclass.
      def matches_pattern?
        self.class::PATTERN =~ number
      end

      # Internal validation method - need to be overriden in subclasses.
      def validate
        raise NoMethodError, "No validate method defined in #{self.class}"
      end

{'fraction_non_alphanumeric': 0.046132008516678494, 'fraction_numerical': 0.0, 'mean_word_length': 2.225400457665904, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2748767', 'n_tokens_mistral': 691, 'n_tokens_neox': 659, 'n_words': 277}