Class: RDF::Normalize::URGNA2012::NormalizationState

Inherits:
RDF::Normalize::URDNA2015::NormalizationState show all
Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-normalize-3ebba07282f6/lib/rdf/normalize/urgna2012.rb

Instance Attribute Summary

Attributes inherited from RDF::Normalize::URDNA2015::NormalizationState

#bnode_to_statements, #canonical_issuer, #hash_to_bnodes

Instance Method Summary collapse

Methods inherited from RDF::Normalize::URDNA2015::NormalizationState

#add_bnode_hash, #add_statement, #hash_first_degree_quads, #hash_n_degree_quads, #initialize

Methods included from Util::Logger

#log_debug, #log_depth, #log_error, #log_fatal, #log_info, #log_recover, #log_recovering?, #log_statistics, #log_warn, #logger

Constructor Details

This class inherits a constructor from RDF::Normalize::URDNA2015::NormalizationState

Instance Method Details

Returns the SHA1 hexdigest hash

Parameters:

Returns:

  • (String)

    the SHA1 hexdigest hash



22
23
24
25
26
27
28
29
30
31
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-normalize-3ebba07282f6/lib/rdf/normalize/urgna2012.rb', line 22

def hash_related_node(related, statement, issuer, position)
  identifier = canonical_issuer.identifier(related) ||
               issuer.identifier(related) ||
               hash_first_degree_quads(related)
  input = position.to_s
  input << statement.predicate.to_s
  input << identifier
  log_debug("hrel") {"input: #{input.inspect}, hash: #{hexdigest(input)}"}
  hexdigest(input)
end

In URGNA2012, the position parameter passed to the Hash Related Blank Node algorithm was instead modeled as a direction parameter, where it could have the value p, for property, when the related blank node was a subject and the value r, for reverse or reference, when the related blank node was an object. Since URGNA2012 only normalized graphs, not datasets, there was no use of the graph position.



34
35
36
37
38
39
40
41
42
43
44
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-normalize-3ebba07282f6/lib/rdf/normalize/urgna2012.rb', line 34

def hash_related_statement(identifier, statement, issuer, map)
  if statement.subject.node? && statement.subject != identifier
    hash = log_depth {hash_related_node(statement.subject, statement, issuer, :p)}
    map[hash] ||= []
    map[hash] << statement.subject unless map[hash].include?(statement.subject)
  elsif statement.object.node? && statement.object != identifier
    hash = log_depth {hash_related_node(statement.object, statement, issuer, :r)}
    map[hash] ||= []
    map[hash] << statement.object unless map[hash].include?(statement.object)
  end
end

#hexdigest(val) ⇒ Object (protected)

2012 version uses SHA-1



13
14
15
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-normalize-3ebba07282f6/lib/rdf/normalize/urgna2012.rb', line 13

def hexdigest(val)
  Digest::SHA1.hexdigest(val)
end