owmeta_core.graph_object module¶
- exception owmeta_core.graph_object.IdentifierMissingException(dataObject='[unspecified object]', *args, **kwargs)[source]¶
Bases:
ExceptionIndicates that an identifier should be available for the object in question, but there is none
- class owmeta_core.graph_object.ComponentTripler(start, traverse_undefined=False, generator=False)[source]¶
Bases:
objectGets a set of triples that are connected to the given object by objects which have an identifier.
The ComponentTripler does not query against a backing graph, but instead uses the properties attached to the object.
- class owmeta_core.graph_object.DescendantTripler(start, graph=None, transitive=True)[source]¶
Bases:
objectGets triples that the object points to, optionally transitively.
- Parameters
- start
GraphObject the node to start from
- graph
rdflib.graph.Graph,optional if given, the graph to draw descedants from. Otherwise the object graph is used
- start
- class owmeta_core.graph_object.GraphObject(**kwargs)[source]¶
Bases:
objectAn object which can be included in the object graph.
An abstract base class.
- variable()[source]¶
Must return a
Variableobject that identifies thisGraphObjectin queries.The variable can be randomly generated when the object is created and stored in the object.
- property defined¶
Returns true if an
identifier()would return an identifier
- property identifier¶
Must return an object representing this object or else raise an Exception.
- class owmeta_core.graph_object.GraphObjectChecker(query_object, graph, sort_first=False)[source]¶
Bases:
objectChecks the graph of defined GraphObjects for
- class owmeta_core.graph_object.GraphObjectQuerier(q, graph, hop_scorer=None)[source]¶
Bases:
objectPerforms queries for objects in the given graph.
The querier queries for objects at the center of a star graph. In SPARQL, the query has the form:
SELECT ?x WHERE { ?x <p1> ?o1 . ?o1 <p2> ?o2 . ... ?on <pn> <a> . ?x <q1> ?n1 . ?n1 <q2> ?n2 . ... ?nn <qn> <b> . }It is allowed that
<px> == <py>forx != y.Queries such as:
SELECT ?x WHERE { ?x <p1> ?o1 . ... ?on <pn> ?y . }or:
SELECT ?x WHERE { ?x <p1> ?o1 . ... ?on <pn> ?x . }or:
SELECT ?x WHERE { ?x ?z ?o . }or:
SELECT ?x WHERE { ?x ?z <a> . }are not supported and will be ignored without error.
Call the GraphObjectQuerier object to perform the query.
- Parameters
- q
GraphObject The object which is queried on
- graph
object The graph from which the objects are queried. Must implement a method
triples()that takes a triple pattern,t, and returns a set of triples matching that pattern. The pattern fortist[i] = None, 0 <= i <= 2, indicates that the i’th position can take any value.The
graphmethod can optionally implement the ‘range query’ ‘interface’: the graph must have a propertysupports_range_queriesequal toTrueandtriples()must accept anInRangeobject in the object position of the query triple, but only for literals- hop_scorer
callable() Returns a score for a hop (a four-tuple, (subject, predicate, object, target)) indicating how selective the query would be for that hop, with lower numbers being more selective. In general the score should only take the given hop into account – it should not take previously given hops into account when calculating a score.
- q
- class owmeta_core.graph_object.LegendFinder(start, graph=None)[source]¶
Bases:
objectGets a list of the objects which can not be deleted freely from the transitive closure.
Essentially, this is the ‘mark’ phase of the “mark-and-sweep” garbage collection algorithm.
“Heroes get remembered, but legends never die.”
- class owmeta_core.graph_object.Variable[source]¶
Bases:
intA marker used in
GraphObjectQuerierfor variables in a query