Module: RDF::Normalize

Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-normalize-3ebba07282f6/lib/rdf/normalize.rb,
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-normalize-3ebba07282f6/lib/rdf/normalize/base.rb,
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-normalize-3ebba07282f6/lib/rdf/normalize/urdna2015.rb,
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-normalize-3ebba07282f6/lib/rdf/normalize/urgna2012.rb,
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-normalize-3ebba07282f6/lib/rdf/normalize/writer.rb,
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-normalize-3ebba07282f6/lib/rdf/normalize/format.rb,
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-normalize-3ebba07282f6/lib/rdf/normalize/carroll2001.rb

Overview

RDF::Normalize is an RDF Graph normalization 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)

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: Base, VERSION Classes: Carroll2001, Format, URDNA2015, URGNA2012, Writer

Constant Summary collapse

ALGORITHMS =
{
  carroll2001: :Carroll2001,
  urgna2012:   :URGNA2012,
  urdna2015:   :URDNA2015
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#datasetRDF::Enumerable

Enumerable to normalize

Returns:



40
41
42
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-normalize-3ebba07282f6/lib/rdf/normalize.rb', line 40

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: :urdna2015

    One of :carroll2001, :urgna2012, or :urdna2015

Returns:

Raises:

  • (ArgumentError)

    selected algorithm not defined



56
57
58
59
60
61
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-normalize-3ebba07282f6/lib/rdf/normalize.rb', line 56

def new(enumerable, options = {})
  algorithm = options.fetch(:algorithm, :urdna2015)
  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