| Home | Trees | Index | Help |
|---|
| Package rdflib :: Module Graph :: Class Graph |
|
object--+ |Node--+ | Graph
ConjunctiveGraph,
QuotedGraph
An RDF Graph
The constructor accepts one argument, the 'store'
that will be used to store the graph data (see the 'store'
package for stores currently shipped with rdflib).
Stores can be context-aware or unaware. Unaware stores take up
(some) less space but cannot support features that require
context, such as true merging/demerging of sub-graphs and
provenance.
The Graph constructor can take an identifier which identifies the Graph
by name. If none is given, the graph is assigned a BNode for it's identifier.
For more on named graphs, see: http://www.w3.org/2004/03/trix/
Ontology for __str__ provenance terms:
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix : <http://rdflib.net/store/> .
@prefix rdfg: <http://www.w3.org/2004/03/trix/rdfg-1/>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
:Store a owl:Class;
rdfs:subClassOf <http://xmlns.com/wordnet/1.6/Electronic_database>;
rdfs:subClassOf
[a owl:Restriction;
owl:onProperty rdfs:label;
owl:allValuesFrom [a owl:DataRange;
owl:oneOf ("IOMemory"
"Sleepcat"
"MySQL"
"Redland"
"REGEXMatching"
"ZODB"
"AuditableStorage"
"Memory")]
].
:ConjunctiveGraph a owl:Class;
rdfs:subClassOf rdfg:Graph;
rdfs:label "The top-level graph within the store - the union of all the Graphs within."
rdfs:seeAlso <http://rdflib.net/rdf_store/#ConjunctiveGraph>.
:DefaultGraph a owl:Class;
rdfs:subClassOf rdfg:Graph;
rdfs:label "The 'default' subgraph of a conjunctive graph".
:identifier a owl:Datatypeproperty;
rdfs:label "The store-associated identifier of the formula. ".
rdfs:domain log:Formula
rdfs:range xsd:anyURI;
:storage a owl:ObjectProperty;
rdfs:domain [
a owl:Class;
owl:unionOf (log:Formula rdfg:Graph :ConjunctiveGraph)
];
rdfs:range :Store.
:default_context a owl:FunctionalProperty;
rdfs:label "The default context for a conjunctive graph";
rdfs:domain :ConjunctiveGraph;
rdfs:range :DefaultGraph.
{?cg a :ConjunctiveGraph;:storage ?store}
=> {?cg owl:sameAs ?store}.
{?subGraph rdfg:subGraphOf ?cg;a :DefaultGraph}
=> {?cg a :ConjunctiveGraph;:default_context ?subGraphOf} .
| Method Summary | |
|---|---|
__init__(self,
store,
identifier,
namespace_manager)
| |
__cmp__(self,
other)
| |
Support for 'triple in graph' syntax | |
__hash__(self)
| |
Add all triples in Graph other to Graph | |
Subtract all triples in Graph other from Graph | |
Iterates over all triples in the store | |
Returns the number of triples in the graph | |
__reduce__(self)
| |
__repr__(self)
| |
__str__(self)
| |
Turn uri into an absolute URI if it's not one already | |
Add a triple with self as context | |
Add a sequence of triple with context | |
all_nodes(self)
| |
Bind prefix to namespace | |
Close the graph store | |
Query for the RDFS.comment of the subject | |
Commits active transactions | |
compute_qname(self,
uri)
| |
Check if the Graph is connected | |
Destroy the store identified by `configuration` if supported | |
isomorphic(self,
other)
| |
Generator over all items in the resource specified by list | |
Query for the RDFS.label of the subject | |
load(self,
source,
publicID,
format)
| |
return an n3 identifier for the Graph | |
Generator over all the prefix, namespace tuples | |
A generator of objects with the given subject and predicate | |
Open the graph store | |
Parse source into Graph | |
A generator of (predicate, object) tuples for the given subject | |
A generator of predicates with the given subject and object | |
prepare_input_source(self,
source,
publicID)
| |
qname(self,
uri)
| |
Executes a SPARQL query (eventually will support Versa queries with same method) against this Graph strOrQuery - Is either a string consisting of the SPARQL query or an instance of rdflib.sparql.bison.Query.Query initBindings - A mapping from a Variable to an RDFLib term (used as initial bindings for SPARQL query) initNS - A mapping from a namespace prefix to an instance of rdflib.Namespace (used for SPARQL query) DEBUG - A boolean flag passed on to the SPARQL parser and evaluation engine processor - The kind of RDF query (must be 'sparql' until Versa is ported) | |
Remove a triple from the graph | |
Rollback active transactions | |
Check if subject is an rdf:Seq | |
Serialize the Graph to destination | |
Convenience method to update the value of object | |
A generator of (subject, object) tuples for the given predicate | |
A generator of (subject, predicate) tuples for the given object | |
A generator of subjects with the given predicate and object | |
Transitively generate objects for the `property` relationship | |
Transitively generate objects for the `property` relationship | |
Generator over the triple store | |
triples_choices(self,
(subject,
predicate,
object_),
context)
| |
Get a value for a pair of two criteria Exactly one of subject, predicate, object must be None. | |
| Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value | |
| Property Summary | |
|---|---|
identifier | |
namespace_manager | |
store | |
| Class Variable Summary | |
|---|---|
| Inherited from Node | |
Implements |
__implemented__ = <implementedBy rdflib.Node.Node>
|
ClassProvides |
__providedBy__ = <zope.interface.declarations.ClassProvi...
|
ClassProvides |
__provides__ = <zope.interface.declarations.ClassProvide...
|
tuple |
__slots__ = ()
|
| Method Details |
|---|
__contains__(self,
triple)
Support for 'triple in graph' syntax
|
__iadd__(self, other)Add all triples in Graph other to Graph |
__isub__(self, other)Subtract all triples in Graph other from Graph |
__iter__(self)Iterates over all triples in the store |
__len__(self)
|
absolutize(self, uri, defrag=1)Turn uri into an absolute URI if it's not one already |
add(self, (s, p, o))Add a triple with self as context |
addN(self, quads)Add a sequence of triple with context |
bind(self, prefix, namespace, override=True)Bind prefix to namespace If override is True will bind namespace to given prefix if namespace was already bound to a different prefix. |
close(self)Close the graph store Might be necessary for stores that require closing a connection to a database or releasing some resource. |
comment(self, subject, default='')Query for the RDFS.comment of the subject Return default if no comment exists |
commit(self)Commits active transactions |
connected(self)Check if the Graph is connected The Graph is considered undirectional. Performs a search on the Graph, starting from a random node. Then iteratively goes depth-first through the triplets where the node is subject and object. Return True if all nodes have been visited and False if it cannot continue and there are still unvisited nodes left. |
destroy(self, configuration)Destroy the store identified by `configuration` if supported |
items(self, list)Generator over all items in the resource specified by list list is an RDF collection. |
label(self, subject, default='')Query for the RDFS.label of the subject Return default if no label exists |
n3(self)return an n3 identifier for the Graph |
namespaces(self)Generator over all the prefix, namespace tuples |
objects(self, subject=None, predicate=None)A generator of objects with the given subject and predicate |
open(self, configuration, create=False)Open the graph store Might be necessary for stores that require opening a connection to a database or acquiring some resource. |
parse(self, source, publicID=None, format='xml', **args)Parse source into Graph If Graph is context-aware it'll get loaded into it's own context (sub graph). Format defaults to xml (AKA rdf/xml). The publicID argument is for specifying the logical URI for the case that it's different from the physical source URI. Returns the context into which the source was parsed. |
predicate_objects(self, subject=None)A generator of (predicate, object) tuples for the given subject |
predicates(self, subject=None, object=None)A generator of predicates with the given subject and object |
query(self, strOrQuery, initBindings={}, initNs={}, DEBUG=False, processor='sparql')Executes a SPARQL query (eventually will support Versa queries with same method) against this Graph strOrQuery - Is either a string consisting of the SPARQL query or an instance of rdflib.sparql.bison.Query.Query initBindings - A mapping from a Variable to an RDFLib term (used as initial bindings for SPARQL query) initNS - A mapping from a namespace prefix to an instance of rdflib.Namespace (used for SPARQL query) DEBUG - A boolean flag passed on to the SPARQL parser and evaluation engine processor - The kind of RDF query (must be 'sparql' until Versa is ported) |
remove(self, (s, p, o))Remove a triple from the graph If the triple does not provide a context attribute, removes the triple from all contexts. |
rollback(self)Rollback active transactions |
seq(self, subject)Check if subject is an rdf:Seq If yes, it returns a Seq class instance, None otherwise. |
serialize(self, destination=None, format='xml', base=None, encoding=None)Serialize the Graph to destination If destination is None serialize method returns the serialization as a string. Format defaults to xml (AKA rdf/xml). |
set(self, (subject, predicate, object))Convenience method to update the value of object Remove any existing triples for subject and predicate before adding (subject, predicate, object). |
subject_objects(self, predicate=None)A generator of (subject, object) tuples for the given predicate |
subject_predicates(self, object=None)A generator of (subject, predicate) tuples for the given object |
subjects(self, predicate=None, object=None)A generator of subjects with the given predicate and object |
transitive_objects(self, subject, property, remember=None)Transitively generate objects for the `property` relationship Generated objects belong to the depth first transitive closure of the `property` relationship starting at `subject`. |
transitive_subjects(self, predicate, object, remember=None)Transitively generate objects for the `property` relationship Generated objects belong to the depth first transitive closure of the `property` relationship starting at `subject`. |
triples(self, (s, p, o))Generator over the triple store Returns triples that match the given triple pattern. If triple pattern does not provide a context, all contexts will be searched. |
value(self, subject=None, predicate=u'http://www.w3.org/1999/02/22-rdf-syntax-ns#value', object=None, default=None, any=False)
Get a value for a pair of two criteria
Exactly one of subject, predicate, object must be None. Useful if one
knows that there may only be one value.
It is one of those situations that occur a lot, hence this
'macro' like utility
Parameters:
-----------
subject, predicate, object -- exactly one must be None
default -- value to be returned if no values found
any -- if True:
return any value in the case there is more than one
else:
raise UniquenessError
|
| Home | Trees | Index | Help |
|---|
| Generated by Epydoc 2.1 on Mon Oct 23 14:11:25 2006 | http://epydoc.sf.net |