You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Updates a node map from which annotations have been folded into embedded triples to re-extract the annotations.
206
+
# Updates a node map from which annotations have been folded into reified triples to re-extract the annotations.
214
207
#
215
-
# Map entries where the key is of the form of a canonicalized JSON object are used to find keys with the `@id` and property components. If found, the original map entry is removed and entries added to an `@annotation` property of the associated value.
208
+
# Map entries having an `@reifies` key are used to find map entries that have a key based on the reification `@id` and a matching value. If found, the original map entry is removed and entries added to an `@annotation` property of the associated value.
216
209
#
217
-
# * Keys which are of the form of a canonicalized JSON object are examined in inverse order of length.
218
-
# * Deserialize the key into a map, and re-serialize the value of `@id`.
219
-
# * If the map contains an entry with that value (after re-canonicalizing, as appropriate), and the associated antry has a item which matches the non-`@id` item from the map, the node is used to create an `@annotation` entry within that value.
210
+
# * If the map contains an entry with that value, and the associated antry has a item which matches the non-`@id` item from the map, the node is used to create an `@annotation` entry within that value.
220
211
#
221
212
# @param [Hash{String => Hash}] node_map
222
213
# @return [Hash{String => Hash}]
223
214
defcreate_annotations(node_map)
224
-
node_map.keys
225
-
.select{ |k| k.start_with?('{')}
226
-
.sort_by(&:length)
227
-
.reverse_eachdo |key|
228
-
annotation=node_map[key]
229
-
# Deserialize key, and re-serialize the `@id` value.
230
-
emb=annotation['@id'].dup
231
-
id=emb.delete('@id')
232
-
property,value=emb.to_a.first
233
-
234
-
# If id is a map, set it to the result of canonicalizing that value, otherwise to itself.
235
-
id=id.to_json_c14nifid.is_a?(Hash)
236
-
237
-
nextunlessnode_map.key?(id)
238
-
239
-
# If node map has an entry for id and that entry contains the same property and value from entry:
# If property is @type, construct triple as an RDF Triple composed of id, rdf:type, and object from values where id and object are represented either as IRIs or Blank Nodes
0 commit comments