Module: RDF::Normalize

Included in:
Canonicalize
Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-normalize-5170ab39c807/lib/rdf/normalize.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-normalize-5170ab39c807/lib/rdf/normalize/base.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-normalize-5170ab39c807/lib/rdf/normalize/format.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-normalize-5170ab39c807/lib/rdf/normalize/rdfc10.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-normalize-5170ab39c807/lib/rdf/normalize/writer.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-normalize-5170ab39c807/lib/rdf/normalize/urgna2012.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-normalize-5170ab39c807/lib/rdf/normalize/carroll2001.rb

Overview

RDF::Normalize is an RDF Graph canonicalization plugin for RDF.rb.

Examples:

Requiring the RDF::Normalize module

require 'rdf/normalize'

Returning an iterator for normalized statements


g = RDF::Graph.load("etc/doap.ttl")
RDF::Normalize.new(g).each_statement do |statement
  puts statement.inspect
end

Returning normalized N-Quads


g = RDF::Graph.load("etc/doap.ttl")
g.dump(:normalize) # or :canonicalize

Writing a repository as normalized N-Quads


RDF::Normalize::Writer.open("etc/doap.nq") do |writer|
  writer << RDF::Repository.load("etc/doap.ttl")
end

Author:

Defined Under Namespace

Modules: VERSION Classes: Base, Carroll2001, Format, MaxCallsExceeded, RDFC10, URGNA2012, UnknownHashAlgorithm, Writer

Constant Summary collapse

ALGORITHMS =
{
  carroll2001: :Carroll2001,
  urgna2012:   :URGNA2012,
  rdfc10:   :RDFC10
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#datasetRDF::Enumerable

Enumerable to normalize

Returns:



41
42
43
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-normalize-5170ab39c807/lib/rdf/normalize.rb', line 41

def dataset
  @dataset
end

Class Method Details

.new(enumerable, **options) ⇒ RDF::Normalize::Base

Creates a new normalizer instance using either the specified or default normalizer algorithm

Parameters:

Options Hash (**options):

  • :algorithm (Base) — default: :rdfc10

    One of :carroll2001, :urgna2012, or :rdfc10

  • :max_calls (Integer)

    Maximum number of calls allowed for recursive blank node labeling, as a multiple of the total number of blank nodes in the dataset.

  • :identifier_map (Boolean)

Returns:

Raises:

  • (ArgumentError)

    selected algorithm not defined



61
62
63
64
65
66
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-normalize-5170ab39c807/lib/rdf/normalize.rb', line 61

def new(enumerable, **options)
  algorithm = options.fetch(:algorithm, :rdfc10)
  raise ArgumentError, "No algoritm defined for #{algorithm.to_sym}" unless ALGORITHMS.has_key?(algorithm)
  algorithm_class = const_get(ALGORITHMS[algorithm])
  algorithm_class.new(enumerable, **options)
end