How to create our own classes and object Properties using RDFLIB python?

22 views
Skip to first unread message

manojms...@gmail.com

unread,
Feb 10, 2020, 2:54:44 PM2/10/20
to rdflib-dev
I want to create below tripples using RDFLIB in python and add it to apache jena database. I am not exactly getting how can I create classes and peoperties using RDFLIB. Please let me know regarding this.

```
State a rdfs:Class .
:City a rdfs:Class .
:locatedIn a rdf:Property .
:capitalOf rdfs:subPropertyOf :locatedIn . 
:capitalOf rdfs:domain :City .
:capitalOf rdfs:range :State .
```

and also for this


```
Example:UsedCarForSale    RDF:type    RDF:Class
Example:Price RDF:type RDFS:Property
Example:PastOwners RDF:Type RDFS:Property
```

Nicholas Car

unread,
Feb 11, 2020, 8:05:40 PM2/11/20
to rdfli...@googlegroups.com
See this code within an API of mine that generated RDF from content in a Postgres DB:


You can see an rdflib in-memory graph is created (‘g’) and then Namespaces for it are declared and bound to it. Triples are then added to that graph using g.add(()).

To get and RDF file from the in-memory graph, just do g.serialize(format=‘turtle’) or whatever format you like.

Nick

— 
Dr Nicholas Car
Data Systems Architect
SURROUND Australia
0477 560 177

On 11 Feb 2020, at 6:54 am, manojms...@gmail.com wrote:


--
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 rdflib-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rdflib-dev/9d57e692-4fe9-4225-b6f0-94b81b18bb32%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages