<commit_before>module Arel
  module Predicates
    class Predicate < Struct.new(:children)
      def or(other_predicate)
        Or.new(self, other_predicate)
      end

      def and(other_predicate)
        And.new(self, other_predicate)
      end

      def complement
        Not.new(self)
      end

      def not
        self.complement
      end

      def == other
        super || (self.class === other && children == other.children)
      end
    end

    class Polyadic < Predicate
      alias :predicates :children

      def initialize(*predicates)
        super(predicates)
      end

      # Build a Polyadic predicate based on:
      # * <tt>operator</tt> - The Predicate subclass that defines the type of operation
      #   (LessThan, Equality, etc)
      # * <tt>operand1</tt> - The left-hand operand (normally an Arel::Attribute)
      # * <tt>additional_operands</tt> - All possible right-hand operands
      def self.build(operator, operand1, *additional_operands)
        new(
          *additional_operands.uniq.inject([]) do |predicates, operand|
            predicates << operator.new(operand1, operand)
          end
        )
      end

      def ==(other)
        super || children == other.children
      end

      def bind(relation)
        self.class.new(
          *predicates.map {|p| p.find_correlate_in(relation)}
        )
      end
    end

    class Any < Polyadic
      def complement
        All.new(*predicates.map {|p| p.complement})
      end
    end

    class All < Polyadic
      def complement
        Any.new(*predicates.map {|p| p.complement})
      end
    end

    class Unary < Predicate
      alias :operand :children

      def bind(relation)
        self.class.new(operand.find_correlate_in(relation))
      end
    end<commit_msg>superclass == works great!<commit_after>module Arel
  module Predicates
    class Predicate < Struct.new(:children)
      def or(other_predicate)
        Or.new(self, other_predicate)
      end

      def and(other_predicate)
        And.new(self, other_predicate)
      end

      def complement
        Not.new(self)
      end

      def not
        self.complement
      end

      def == other
        super || (self.class === other && children == other.children)
      end
    end

    class Polyadic < Predicate
      alias :predicates :children

      def initialize(*predicates)
        super(predicates)
      end

      # Build a Polyadic predicate based on:
      # * <tt>operator</tt> - The Predicate subclass that defines the type of operation
      #   (LessThan, Equality, etc)
      # * <tt>operand1</tt> - The left-hand operand (normally an Arel::Attribute)
      # * <tt>additional_operands</tt> - All possible right-hand operands
      def self.build(operator, operand1, *additional_operands)
        new(
          *additional_operands.uniq.inject([]) do |predicates, operand|
            predicates << operator.new(operand1, operand)
          end
        )
      end

      def bind(relation)
        self.class.new(
          *predicates.map {|p| p.find_correlate_in(relation)}
        )
      end
    end

    class Any < Polyadic
      def complement
        All.new(*predicates.map {|p| p.complement})
      end
    end

    class All < Polyadic
      def complement
        Any.new(*predicates.map {|p| p.complement})
      end
    end

    class Unary < Predicate
      alias :operand :children

      def bind(relation)
        self.class.new(operand.find_correlate_in(relation))
      end
    end
{'fraction_non_alphanumeric': 0.09277177006260671, 'fraction_numerical': 0.001707455890722823, 'mean_word_length': 2.0512152777777777, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 15, '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': '4986689', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1036, 'n_words': 263}