<commit_before>module RDF
  module SPARQL
    module Common

      ##
      # Yields each statement of SPARQL query
      # @yield  [statement]
      # @yieldparam [Statement]
      # @return [Reader]
      ##
      def each_statement(&block)
        @graph.each_statement { |statement| block.call(statement) }
        self
      end

      ##
      # Yields each triple of SPARQL query
      # @yield  [triple]
      # @yieldparam [Array(Value)]
      # @return [Reader]
      ##
      def each_triple(&block)
        @graph.each_triple { |*triple| block.call(*triple) }
        self
      end

      ##
      # Yields each target variable in SPARQL query
      # @yield  [variable]
      # @yieldparam [Variable]
      # @return [Reader]
      ##
      def each_target(&block)
        @targets.each { |target| block.call(target) }
        self
      end

      ##
      # Yields each variable in SPARQL query
      # @yield  [variable]
      # @yieldparam [Variable]
      # @return [Reader]
      ##
      def each_variable(&block)
        variables.each { |variable| block.call(variable) }
        self
      end

      ##
      # [-]
      ##
      def targets
        @targets
      end
      
      ##
      # [-]
      ##
      def statements
        @graph.statements
      end

      ##
      # [-]
      ##
      def triples
        @graph.triples
      end

      ##
      # [-]
      ##
      def variables
        Hash[@graph.map { |pattern|
          pattern.variables.values
        }.flatten.uniq.map { |variable|
          [variable.name, variable]
        }]
      end

      ##
      # [-]
      ##
      def type
        @type || @options[:type]
      end
      
      ##
      # Check whether `distinct` flag was specified
      # @return [Boolean]
      ##
      def distinct?
        @options[:distinct] == true
      end

      ##
      # Check whether `reduced` flag was specified
      # @return [Boolean]
      ##
      def reduced?
        @options[:reduced] == true
      end

    end # Common
  end # SPARQL
end # RDF<commit_msg>Reader and Writer now implement RDF::Enumerable<commit_after>module RDF
  module SPARQL
    module Common
      
      include RDF::Enumerable
      
      ##
      # Yields each statement of SPARQL query.
      # @yield  [statement]
      # @yieldparam [Statement]
      # @return [Reader]
      ##
      def each(&block)
        @graph.each_statement { |statement| block.call(statement) }
        self
      end

      ##
      # Yields each target variable in SPARQL query
      # @yield  [variable]
      # @yieldparam [Variable]
      # @return [Reader]
      ##
      def each_target(&block)
        @targets.each { |target| block.call(target) }
        self
      end

      ##
      # Yields each variable in SPARQL query
      # @yield  [variable]
      # @yieldparam [Variable]
      # @return [Reader]
      ##
      def each_variable(&block)
        variables.each { |variable| block.call(variable) }
        self
      end

      ##
      # Returns all requested variables.
      # @return [Array<RDF::Query::Variable>]
      ##
      def targets
        @targets.dup
      end
      
      ##
      # Returns all variables.
      # @return [Array<RDF::Query::Variable>]
      ##
      def variables
        @graph.statements.map(&:to_a).flatten.select(&:variable?)
      end

      ##
      # Returns query type (:select, :describe, :ask or :construct).
      # @return [Symbol]
      # @return [nil] if undefined
      ##
      def type
        @type || @options[:type]
      end
      
      ##
      # Returns true if `distinct` flag is specified.
      # @return [Boolean]
      ##
      def distinct?
        @options[:distinct] == true
      end

      ##
      # Returns true if `reduced` flag is specified,
      # @return [Boolean]
      ##
      def reduced?
        @options[:reduced] == true
      end

    end # Common
  end # SPARQL
end # RDF
{'fraction_non_alphanumeric': 0.11348600508905853, 'fraction_numerical': 0.0, 'mean_word_length': 1.577704918032787, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2177279', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1151, 'n_words': 284}