<s>
RDFLib	B-Library
is	O
a	O
Python	B-Language
library	B-Library
for	O
working	O
with	O
RDF	O
,	O
a	O
simple	O
yet	O
powerful	O
language	O
for	O
representing	O
information	O
.	O
</s>
<s>
This	O
library	B-Library
contains	O
parsers/serializers	O
for	O
almost	O
all	O
of	O
the	O
known	O
RDF	O
serializations	O
,	O
such	O
as	O
RDF/XML	O
,	O
Turtle	O
,	O
N-Triples	O
,	O
&	O
JSON-LD	B-Protocol
,	O
many	O
of	O
which	O
are	O
now	O
supported	O
in	O
their	O
updated	O
form	O
(	O
e.g.	O
</s>
<s>
The	O
library	B-Library
also	O
contains	O
both	O
in-memory	O
and	O
persistent	O
Graph	B-Application
back-ends	O
for	O
storing	O
RDF	O
information	O
and	O
numerous	O
convenience	O
functions	O
for	O
declaring	O
graph	B-Application
namespaces	O
,	O
lodging	O
SPARQL	B-Language
queries	O
and	O
so	O
on	O
.	O
</s>
<s>
A	O
number	O
of	O
other	O
Python	B-Language
projects	O
use	O
rdflib	B-Library
for	O
RDF	O
manipulation	O
,	O
including	O
:	O
</s>
<s>
RDFLib	B-Library
's	O
use	O
of	O
various	O
Python	B-Language
idioms	O
mean	O
it	O
is	O
fairly	O
simple	O
for	O
programmers	O
with	O
only	O
junior	O
Python	B-Language
skills	O
to	O
manipulate	O
RDF	O
.	O
</s>
<s>
On	O
the	O
other	O
hand	O
,	O
the	O
Python	B-Language
idioms	O
are	O
simple	O
enough	O
that	O
someone	O
familiar	O
with	O
RDF	O
,	O
but	O
not	O
Python	B-Language
,	O
can	O
probably	O
work	O
out	O
how	O
to	O
use	O
rdflib	B-Library
quite	O
easily	O
.	O
</s>
<s>
The	O
core	O
class	O
in	O
RDFLib	B-Library
is	O
which	O
is	O
a	O
Python	B-Language
dictionary	O
used	O
to	O
store	O
collections	O
of	O
RDF	O
triples	O
in	O
memory	O
.	O
</s>
<s>
It	O
redefines	O
certain	O
built-in	O
Python	B-Language
object	O
methods	O
in	O
order	O
to	O
exhibit	O
simple	O
graph	B-Application
behaviour	O
,	O
such	O
as	O
simple	O
graph	B-Application
merging	O
via	O
addition	O
(	O
i.e.	O
</s>
<s>
RDFLib	B-Library
graphs	O
emulate	O
container	O
types	O
and	O
are	O
best	O
thought	O
of	O
as	O
a	O
set	O
of	O
3-item	O
triples	O
:	O
</s>
<s>
RDFLib	B-Library
graphs	O
are	O
not	O
sorted	O
containers	O
;	O
they	O
have	O
ordinary	O
Python	B-Language
set	O
operations	O
,	O
e.g.	O
</s>
<s>
The	O
following	O
RDFLib	B-Library
classes	O
(	O
listed	O
below	O
)	O
model	O
in	O
a	O
graph	B-Application
and	O
inherit	O
from	O
a	O
common	O
class	O
,	O
which	O
extends	O
Python	B-Language
unicode	O
.	O
</s>
<s>
Instances	O
of	O
these	O
are	O
nodes	O
in	O
an	O
RDF	O
graph	B-Application
.	O
</s>
<s>
RDFLib	B-Library
provides	O
mechanisms	O
for	O
managing	O
namespaces	O
.	O
</s>
<s>
RDFLib	B-Library
graphs	O
also	O
override	O
__iter__	O
in	O
order	O
to	O
support	O
iteration	B-Algorithm
over	O
the	O
contained	O
triples	O
:	O
</s>
<s>
RDFLib	B-Library
graphs	O
support	O
basic	O
triple	O
pattern	O
matching	O
with	O
a	O
triples((subject,predicate,object )	O
)	O
function	O
.	O
</s>
<s>
The	O
first	O
argument	O
can	O
be	O
a	O
source	O
of	O
many	O
kinds	O
,	O
but	O
the	O
most	O
common	O
is	O
the	O
serialization	O
(	O
in	O
various	O
formats	O
:	O
RDF/XML	O
,	O
Notation	O
3	O
,	O
N-Triples	O
of	O
an	O
RDF	O
graph	B-Application
as	O
a	O
string	O
)	O
.	O
</s>
<s>
The	O
format	O
parameter	O
is	O
one	O
of	O
turtle	O
,	O
n3	O
,	O
xml	O
,	O
n-triples	O
or	O
JSON-LD	B-Protocol
(	O
this	O
last	O
when	O
the	O
JSON-LD	B-Protocol
plugin	O
is	O
used	O
)	O
.	O
</s>
<s>
publicID	O
is	O
the	O
name	O
of	O
the	O
graph	B-Application
into	O
which	O
the	O
RDF	O
serialization	O
will	O
be	O
parsed	O
.	O
</s>
<s>
RDFLib	B-Library
'	O
Literal	O
's	O
essentially	O
behave	O
like	O
Unicode	O
characters	O
with	O
an	O
XML	O
Schema	O
datatype	O
or	O
language	O
attribute	O
.	O
</s>
<s>
The	O
class	O
provides	O
a	O
mechanism	O
to	O
both	O
convert	O
Python	B-Language
literals	O
(	O
and	O
their	O
built-ins	O
such	O
as	O
time/date/datetime	O
)	O
into	O
equivalent	O
RDF	O
Literals	O
and	O
(	O
conversely	O
)	O
convert	O
Literals	O
to	O
their	O
Python	B-Language
equivalent	O
.	O
</s>
<s>
This	O
mapping	O
to	O
and	O
from	O
Python	B-Language
literals	O
is	O
achieved	O
with	O
the	O
following	O
dictionaries	O
:	O
</s>
<s>
Maps	O
WXS	O
datatyped	O
Literals	O
to	O
Python	B-Language
.	O
</s>
<s>
RDFLIb	B-Library
supports	O
a	O
majority	O
of	O
the	O
current	O
SPARQL	B-Language
1.1	I-Language
specification	O
and	O
includes	O
a	O
harness	O
for	O
the	O
publicly	O
available	O
RDF	O
DAWG	O
test	O
suite	O
.	O
</s>
<s>
Support	O
for	O
SPARQL	B-Language
is	O
provided	O
by	O
two	O
methods	O
:	O
</s>
<s>
The	O
motivation	O
is	O
to	O
outline	O
a	O
standard	O
set	O
of	O
interfaces	O
for	O
providing	O
the	O
necessary	O
support	O
needed	O
in	O
order	O
to	O
persist	O
an	O
RDF	O
Graph	B-Application
in	O
a	O
way	O
that	O
is	O
universal	O
and	O
not	O
tied	O
to	O
any	O
specific	O
implementation	O
.	O
</s>
<s>
Also	O
could	O
be	O
called	O
a	O
sub-graph	O
.	O
</s>
<s>
A	O
context	O
could	O
be	O
thought	O
of	O
as	O
only	O
the	O
relationship	O
between	O
an	O
RDF	O
triple	O
and	O
a	O
sub-graph	O
(	O
this	O
is	O
how	O
the	O
term	O
context	O
is	O
used	O
in	O
the	O
Notation	O
3	O
Design	O
Issues	O
page	O
)	O
in	O
which	O
it	O
is	O
found	O
or	O
the	O
sub-graph	O
itself	O
.	O
</s>
<s>
The	O
RDF	O
model	O
defines	O
a	O
graph	B-Application
as	O
an	O
arbitrary	O
collection	O
of	O
triples	O
and	O
the	O
semantics	O
of	O
these	O
triples	O
,	O
but	O
does	O
n't	O
give	O
guidance	O
on	O
how	O
to	O
consistently	O
address	O
such	O
arbitrary	O
collections	O
.	O
</s>
<s>
Conjunctive	O
Graph	B-Application
This	O
refers	O
to	O
the	O
'	O
top-level	O
'	O
Graph	B-Application
.	O
</s>
<s>
It	O
is	O
the	O
aggregation	O
of	O
all	O
the	O
contexts	O
within	O
it	O
and	O
is	O
also	O
the	O
appropriate	O
,	O
absolute	O
boundary	O
for	O
closed	B-Application
world	I-Application
assumptions	I-Application
/	O
models	O
.	O
</s>
<s>
There	O
are	O
at	O
least	O
two	O
situations	O
where	O
the	O
closed	B-Application
world	I-Application
assumption	I-Application
is	O
used	O
.	O
</s>
<s>
From	O
a	O
store	O
perspective	O
,	O
closed	B-Application
world	I-Application
assumptions	I-Application
also	O
provide	O
the	O
benefit	O
of	O
better	O
query	O
response	O
times	O
due	O
to	O
the	O
explicit	O
closed	O
world	O
boundaries	O
.	O
</s>
<s>
So	O
a	O
closed	B-Application
world	I-Application
assumption	I-Application
does	O
not	O
preclude	O
you	O
from	O
an	O
open-world	B-Application
assumption	I-Application
.	O
</s>
<s>
For	O
the	O
sake	O
of	O
persistence	O
,	O
Conjunctive	O
Graphs	O
must	O
be	O
distinguished	O
by	O
identifiers	O
(	O
that	O
may	O
not	O
necessarily	O
be	O
RDF	O
identifiers	O
or	O
may	O
be	O
an	O
RDF	O
identifier	O
normalized	O
-	O
SHA1/MD5	O
perhaps	O
-	O
for	O
database	O
naming	O
purposes	O
)	O
which	O
could	O
be	O
referenced	O
to	O
indicate	O
conjunctive	O
queries	O
(	O
queries	O
made	O
across	O
the	O
entire	O
conjunctive	O
graph	B-Application
)	O
or	O
appear	O
as	O
nodes	O
in	O
asserted	O
statements	O
.	O
</s>
<s>
OWL	B-Language
Definition	O
of	O
SWRL	O
.	O
</s>
<s>
And	O
those	O
that	O
are	O
primarily	O
for	O
matching	O
against	O
'	O
Nodes	O
 '	O
in	O
the	O
underlying	O
Graph	B-Application
:	O
</s>
<s>
"	O
The	O
set	O
of	O
nodes	O
of	O
an	O
RDF	O
graph	B-Application
is	O
the	O
set	O
of	O
subjects	O
and	O
objects	O
of	O
triples	O
in	O
the	O
graph	B-Application
.	O
</s>
<s>
Such	O
a	O
query	O
expects	O
a	O
context-aware	O
store	O
to	O
search	O
the	O
entire	O
asserted	O
universe	O
(	O
the	O
conjunctive	O
graph	B-Application
)	O
.	O
</s>
<s>
Such	O
interfaces	O
are	O
standard	O
to	O
most	O
database	O
management	O
systems	O
(	O
Oracle	O
,	O
MySQL	B-Application
,	O
Berkeley	B-Language
DB	I-Language
,	O
Postgres	O
,	O
etc	O
..	O
)	O
</s>
<s>
-	O
Returns	O
an	O
iterator	O
over	O
all	O
the	O
triples	O
(	O
within	O
the	O
conjunctive	O
graph	B-Application
or	O
just	O
the	O
given	O
context	O
)	O
matching	O
the	O
given	O
pattern	O
.	O
</s>
<s>
A	O
conjunctive	O
query	O
can	O
be	O
indicated	O
by	O
either	O
providing	O
a	O
value	O
of	O
NULL/None/Empty	O
string	O
value	O
for	O
context	O
or	O
the	O
identifier	O
associated	O
with	O
the	O
Conjunctive	O
Graph	B-Application
.	O
</s>
<s>
-	O
Generator	O
over	O
all	O
contexts	O
in	O
the	O
graph	B-Application
.	O
</s>
<s>
RDFLib	B-Library
defines	O
the	O
following	O
kinds	O
of	O
Graphs	O
:	O
</s>
<s>
A	O
Conjunctive	O
Graph	B-Application
is	O
the	O
most	O
relevant	O
collection	O
of	O
graphs	O
that	O
are	O
considered	O
to	O
be	O
the	O
boundary	O
for	O
closed	B-Application
world	I-Application
assumptions	I-Application
.	O
</s>
<s>
It	O
is	O
equivalent	O
to	O
all	O
the	O
named	O
graphs	O
within	O
it	O
and	O
associated	O
with	O
a	O
_default_	O
graph	B-Application
which	O
is	O
automatically	O
assigned	O
a	O
BNode	O
for	O
an	O
identifier	O
-	O
if	O
one	O
is	O
n't	O
given	O
.	O
</s>
<s>
RDFLib	B-Library
graphs	O
support	O
an	O
additional	O
extension	O
of	O
RDF	O
semantics	O
for	O
formulae	O
.	O
</s>
<s>
RDFLib	B-Library
provides	O
an	O
abstracted	O
Store	O
API	B-General_Concept
for	O
persistence	O
of	O
RDF	O
and	O
Notation	O
3	O
.	O
</s>
<s>
The	O
Graph	B-Application
class	O
works	O
with	O
instances	O
of	O
this	O
API	B-General_Concept
(	O
as	O
the	O
first	O
argument	O
to	O
its	O
constructor	O
)	O
for	O
triple-based	O
management	O
of	O
an	O
RDF	O
store	O
including	O
:	O
garbage	O
collection	O
,	O
transaction	O
management	O
,	O
update	O
,	O
pattern	O
matching	O
,	O
removal	O
,	O
length	O
,	O
and	O
database	O
management	O
(	O
)	O
.	O
</s>
<s>
Additional	O
persistence	O
mechanisms	O
can	O
be	O
supported	O
by	O
implementing	O
this	O
API	B-General_Concept
for	O
a	O
different	O
store	O
.	O
</s>
<s>
There	O
are	O
a	O
few	O
high-level	O
APIs	B-General_Concept
that	O
extend	O
RDFLib	B-Library
graphs	O
into	O
other	O
Pythonic	O
idioms	O
.	O
</s>
<s>
For	O
more	O
a	O
more	O
explicit	O
Python	B-Language
binding	O
,	O
there	O
are	O
,	O
&	O
.	O
</s>
