Here's a full example:
-----
import rdflib
from rdflib import RDF, URIRef, Literal
g = rdflib.Graph()
SDO = rdflib.Namespace('https://schema.org/')
g.bind('sdo', SDO)
DEFAULT = rdflib.Namespace('http://example.org/')
g.bind('', DEFAULT)
g.add((
URIRef('http://example.org/person/nick'),
RDF.type,
SDO.Person
))
g.add((
URIRef('http://example.org/person/nick'),
SDO.name,
Literal('Nicholas Car')
))
g.add((
DEFAULT.other,
RDF.type,
SDO.Thing
))
-----
print(g.serialize(format='turtle').decode('utf-8'))
prints:
-----
@prefix : <http://example.org/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sdo: <https://schema.org/> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
:other a sdo:Thing .
<http://example.org/person/nick> a sdo:Person ;
sdo:name "Nicholas Car" .
-----
Nick
On 16/7/19, 9:35 pm, "Nicholas Car" <[email protected]> wrote:
DEFAULT = rdflib.Namespace('http://example.org/')
g.bind('', DEFAULT)
Nick
On 16/7/19, 3:55 am, "[email protected] on behalf of
[email protected]" <[email protected] on behalf of
[email protected]> wrote:
Dear community,
How can I create default prefix with only colon with rdflib?
For instance, I hope to have:
@prefix : <https://xxx> .
<yyy>
rdf:type :fff ;
rdfs:label "example" .
Thanks!
--
http://github.com/RDFLib
---
You received this message because you are subscribed to the Google
Groups "rdflib-dev" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rdflib-dev/fc80b5c7-fd22-488b-9396-d5d3727d1f8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
http://github.com/RDFLib
---
You received this message because you are subscribed to the Google Groups
"rdflib-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rdflib-dev/TY2PR0101MB3152050EA437CDABB2E55F49A2CE0%40TY2PR0101MB3152.apcprd01.prod.exchangelabs.com.
For more options, visit https://groups.google.com/d/optout.