owmeta_core.rdf_utils module¶
- class owmeta_core.rdf_utils.BatchAddGraph(graph, batchsize=1000, _parent=None, *args, **kwargs)[source]¶
Bases:
objectWrapper around graph that turns calls to ‘add’ into calls to ‘addN’
- owmeta_core.rdf_utils.transitive_lookup(graph, start, predicate, context=None, direction='down', seen=None)[source]¶
Do a transitive lookup over an
rdflib.graph.Graphorrdflib.store.StoreIn other words, finds all resources which relate to
startthrough zero or morepredicaterelationships.startitself will be included in the return value.Loops in the input
graphwill not cause non-termination.- Parameters
- graph
rdflib.graph.Graphorrdflib.store.Store The graph to query
- start
rdflib.term.Identifier The resource in the graph to start from
- predicate
rdflib.term.URIRef The predicate relating terms in the closure
- context
rdflib.graph.Graphorrdflib.term.URIRef The context in which the query should run. Optional
- direction
DOWNorUP The direction in which to traverse
- seen
setofrdflib.term.Identifier A set of terms which have already been “seen” by the algorithm. Useful for repeated calls to
transitive_lookup. Note: if thestartis inseen, queries fromstartwill still be done, but any items in the result of those queries will not be queried for if inseen. Optional
- graph
- Returns
setofrdflib.term.Identifierresources in the transitive closure of
predicatefromstart
- owmeta_core.rdf_utils.transitive_subjects(graph, start, predicate, context=None, direction='down', seen=None)¶
Alias to
transitive_lookup
- owmeta_core.rdf_utils.DOWN = 'down'¶
Subject to Object direction for traversal across triples.
- owmeta_core.rdf_utils.UP = 'up'¶
Object to Subject direction for traversal across triples.