<commit_before>module RDF; class Literal
  ##
  # A boolean literal.
  #
  # @see   http://www.w3.org/TR/xmlschema-2/#boolean
  # @since 0.2.1
  class Boolean < Literal
    DATATYPE = XSD.boolean
    GRAMMAR  = /^(true|false|1|0)$/.freeze
    TRUES    = %w(true  1).freeze
    FALSES   = %w(false 0).freeze

    ##
    # @param  [Boolean] value
    # @option options [String] :lexical (nil)
    def initialize(value, options = {})
      @datatype = options[:datatype] || DATATYPE
      @string   = options[:lexical] if options.has_key?(:lexical)
      @object   = case
        when true.equal?(value)          then true
        when false.equal?(value)         then false
        when TRUES.include?(value.to_s)  then true
        when FALSES.include?(value.to_s) then false
        else raise ArgumentError.new("expected true or false, but got #{value.inspect}")
      end
    end

    ##
    # Converts the literal into its canonical lexical representation.
    #<commit_msg>Ensured that RDF::Literal::Boolean won't raise errors when constructed.<commit_after>module RDF; class Literal
  ##
  # A boolean literal.
  #
  # @see   http://www.w3.org/TR/xmlschema-2/#boolean
  # @since 0.2.1
  class Boolean < Literal
    DATATYPE = XSD.boolean
    GRAMMAR  = /^(true|false|1|0)$/.freeze
    TRUES    = %w(true  1).freeze
    FALSES   = %w(false 0).freeze

    ##
    # @param  [Boolean] value
    # @option options [String] :lexical (nil)
    def initialize(value, options = {})
      @datatype = options[:datatype] || DATATYPE
      @string   = options[:lexical] if options.has_key?(:lexical)
      @string   = value if !defined?(@string) && value.is_a?(String)
      @object   = case
        when true.equal?(value)          then true
        when false.equal?(value)         then false
        when TRUES.include?(value.to_s)  then true
        when FALSES.include?(value.to_s) then false
        else value
      end
    end

    ##
    # Converts the literal into its canonical lexical representation.
    #
{'fraction_non_alphanumeric': 0.12381899552461462, 'fraction_numerical': 0.008950770760815515, 'mean_word_length': 2.4334470989761092, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, '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': '4870101', 'n_tokens_mistral': 668, 'n_tokens_neox': 662, 'n_words': 163}