Class: RoadForest::PathMatcher::Node
Instance Attribute Summary collapse
Attributes inherited from MatchStep
#after, #before, #children, #exact_value, #graph, #graph_term, #order, #parent, #pattern, #pattern_step, #repeats, #satified, #stem, #type
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from MatchStep
#initialize, #matched_statements, #open, #pretty_print_instance_variables, #reset
Instance Attribute Details
#statement ⇒ Object
the RDF statement that got here from parent
262
263
264
|
# File 'lib/roadforest/path-matcher.rb', line 262
def statement
@statement
end
|
Class Method Details
.find_child_nodes(edge) ⇒ Object
264
265
266
267
268
269
270
271
272
|
# File 'lib/roadforest/path-matcher.rb', line 264
def self.find_child_nodes(edge)
edge.graph.query(edge.pattern_hash).map do |statement|
next if edge.stem.has_key?(statement)
Node.new do |node|
node.from(edge, statement)
end
end
end
|
Instance Method Details
#accepting? ⇒ Boolean
336
337
338
339
340
341
342
343
344
345
346
347
348
349
|
# File 'lib/roadforest/path-matcher.rb', line 336
def accepting?
@accepting ||=
if excluded?
false
elsif children.nil?
false
elsif reject_value?
false
else
child_edges.all? do |edge|
edge.accepting?
end
end
end
|
#excluded? ⇒ Boolean
311
312
313
|
# File 'lib/roadforest/path-matcher.rb', line 311
def excluded?
stem.has_key?(statement)
end
|
#from(edge, statement) ⇒ Object
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
|
# File 'lib/roadforest/path-matcher.rb', line 274
def from(edge, statement)
self.parent = edge
self.pattern = edge.pattern
self.graph = edge.graph
self.stem = edge.stem
self.repeats = edge.repeats.merge({edge.pattern_step => edge.step_count + 1})
self.graph_term = edge.graph_node(statement)
self.statement = statement
self.pattern_step = edge.pattern_step
self.after = edge.after
self.before = edge.before
self.order = edge.order
self.type = edge.type
end
|
307
308
309
|
# File 'lib/roadforest/path-matcher.rb', line 307
def immediate_match
statement.nil? ? {} : { statement => true }
end
|
#notify_resolved(child) ⇒ Object
315
316
317
|
# File 'lib/roadforest/path-matcher.rb', line 315
def notify_resolved(child)
end
|
#reject_value? ⇒ Boolean
319
320
321
322
323
324
325
326
327
328
329
330
|
# File 'lib/roadforest/path-matcher.rb', line 319
def reject_value?
unless before.nil? and after.nil?
return true if not (before.nil? or before > graph_term)
return true if not (after.nil? and after < graph_term)
end
unless type.nil?
return true if graph_term.datatype != type
end
return false
end
|
#rejecting? ⇒ Boolean
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
|
# File 'lib/roadforest/path-matcher.rb', line 351
def rejecting?
@rejecting ||=
begin
if excluded?
true
elsif children.nil?
false
elsif reject_value?
true
else
child_edges.any? do |edge|
edge.rejecting?
end
end
end
end
|
#resolved? ⇒ Boolean
332
333
334
|
# File 'lib/roadforest/path-matcher.rb', line 332
def resolved?
@resolved ||= accepting? or rejecting?
end
|
#to_s ⇒ Object
295
296
297
298
299
300
301
302
303
304
305
|
# File 'lib/roadforest/path-matcher.rb', line 295
def to_s
state = case
when !resolved?
"?"
when accepting?
"Acpt"
when rejecting?
"Rjct"
end
"[#{self.class.name.sub(/.*::/,'')} #{statement} #{graph_term}/#{pattern_step} #{state} ]"
end
|