Class: RDF::Normalize::URGNA2012::NormalizationState
- Inherits:
-
RDFC10::NormalizationState
- Object
- RDFC10::NormalizationState
- RDF::Normalize::URGNA2012::NormalizationState
- Defined in:
- lib/rdf/normalize/urgna2012.rb
Instance Attribute Summary
Attributes inherited from RDFC10::NormalizationState
#bnode_to_statements, #canonical_issuer, #hash_algorithm, #hash_to_bnodes, #max_calls, #total_calls
Instance Method Summary collapse
-
#hash_related_node(related, statement, issuer, position) ⇒ String
protected
The SHA1 hexdigest hash.
-
#hash_related_statement(identifier, statement, issuer, map) ⇒ Object
protected
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 anobject
. -
#hexdigest(val) ⇒ Object
protected
2012 version uses SHA-1.
Methods inherited from RDFC10::NormalizationState
#add_bnode_hash, #add_statement, #hash_first_degree_quads, #hash_n_degree_quads, #initialize, #inspect, #inspect_bnode_to_statements, #inspect_hash_to_bnodes
Constructor Details
This class inherits a constructor from RDF::Normalize::RDFC10::NormalizationState
Instance Method Details
#hash_related_node(related, statement, issuer, position) ⇒ String (protected)
Returns the SHA1 hexdigest hash.
28 29 30 31 32 33 34 35 |
# File 'lib/rdf/normalize/urgna2012.rb', line 28 def (, statement, issuer, position) identifier = canonical_issuer.identifier() || issuer.identifier() || hash_first_degree_quads() input = "#{position}#{statement.predicate}#{identifier}" log_debug("hrel") {"input: #{input.inspect}, hash: #{hexdigest(input)}"} hexdigest(input) end |
#hash_related_statement(identifier, statement, issuer, map) ⇒ Object (protected)
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.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rdf/normalize/urgna2012.rb', line 38 def (identifier, statement, issuer, map) if statement.subject.node? && statement.subject != identifier hash = log_depth {(statement.subject, statement, issuer, :p)} map[hash] ||= [] map[hash] << statement.subject unless map[hash].any? {|n| n.eql?(statement.subject)} elsif statement.object.node? && statement.object != identifier hash = log_depth {(statement.object, statement, issuer, :r)} map[hash] ||= [] map[hash] << statement.object unless map[hash].any? {|n| n.eql?(statement.object)} end end |
#hexdigest(val) ⇒ Object (protected)
2012 version uses SHA-1
19 20 21 |
# File 'lib/rdf/normalize/urgna2012.rb', line 19 def hexdigest(val) Digest::SHA1.hexdigest(val) end |