<commit_before>module RDF
  ##
  # Classes that include this module must implement the methods
  # `#insert_statement`.
  #
  # @see RDF::Graph
  # @see RDF::Repository
  module Writable
    extend RDF::Util::Aliasing::LateBound

    ##
    # Returns `true` if `self` is writable.
    #
    # @return [Boolean] `true` or `false`
    # @see    RDF::Readable#readable?
    def writable?
      true
    end

    ##
    # Inserts RDF data into `self`.
    #
    # @param  [RDF::Enumerable, RDF::Statement, #to_rdf] data
    # @return [RDF::Writable] `self`
    def <<(data)
      case data
        when RDF::Reader
          insert_reader(data)
        when RDF::Graph
          insert_graph(data)
        when RDF::Enumerable
          insert_statements(data)
        when RDF::Statement
          insert_statement(data)
        else case
          when data.respond_to?(:to_rdf) && !data.equal?(rdf = data.to_rdf)
            self << rdf
          else
            insert_statement(Statement.from(data))
        end
      end

      return self
    end

    ##
    # Inserts RDF statements into `self`.
    #
    # @param  [Array<RDF::Statement>] statements
    # @return [RDF::Writable] `self`
    def insert(*statements)
      statements.map! do |value|
        case
          when value.respond_to?(:each_statement)
            insert_statements(value)
            nil
          when (statement = Statement.from(value)).valid?
            statement
          else
            raise ArgumentError.new("not a valid statement: #{value.inspect}")
        end
      end
      statements.compact!
      insert_statements(statements) unless statements.empty?

      return self
    end
    alias_method :insert!, :insert

  protected
<commit_msg>In Writable#insert, don't require statement to be valid.<commit_after>module RDF
  ##
  # Classes that include this module must implement the methods
  # `#insert_statement`.
  #
  # @see RDF::Graph
  # @see RDF::Repository
  module Writable
    extend RDF::Util::Aliasing::LateBound

    ##
    # Returns `true` if `self` is writable.
    #
    # @return [Boolean] `true` or `false`
    # @see    RDF::Readable#readable?
    def writable?
      true
    end

    ##
    # Inserts RDF data into `self`.
    #
    # @param  [RDF::Enumerable, RDF::Statement, #to_rdf] data
    # @return [RDF::Writable] `self`
    def <<(data)
      case data
        when RDF::Reader
          insert_reader(data)
        when RDF::Graph
          insert_graph(data)
        when RDF::Enumerable
          insert_statements(data)
        when RDF::Statement
          insert_statement(data)
        else case
          when data.respond_to?(:to_rdf) && !data.equal?(rdf = data.to_rdf)
            self << rdf
          else
            insert_statement(Statement.from(data))
        end
      end

      return self
    end

    ##
    # Inserts RDF statements into `self`.
    #
    # @param  [Array<RDF::Statement>] statements
    # @return [RDF::Writable] `self`
    def insert(*statements)
      statements.map! do |value|
        case
          when value.respond_to?(:each_statement)
            insert_statements(value)
            nil
          when (statement = Statement.from(value))
            statement
          else
            raise ArgumentError.new("not a valid statement: #{value.inspect}")
        end
      end
      statements.compact!
      insert_statements(statements) unless statements.empty?

      return self
    end
    alias_method :insert!, :insert

  protected

{'fraction_non_alphanumeric': 0.10409556313993173, 'fraction_numerical': 0.0, 'mean_word_length': 2.0850877192982455, 'pattern_counts': {'":': 0, '<': 13, '<?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': '6782688', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1036, 'n_words': 259}