ARTIFACTS / Software / OntoInspector
DATE: Jun 2011
URL: https://bitbucket.org/magicrebirth/ontoinspector/overview
URL: Blog post: Inspecting an ontology with rdflib
URL: https://bitbucket.org/magicrebirth/ontoinspector/overview
URL: Blog post: Inspecting an ontology with rdflib
A minimal python toolkit for viewing and querying RDFS/OWL ontologies, based on RDFLib.
I use it mainly as a way to access programmatically the main taxonomy of an ontology and its classes (not the properties yet).
I'm working on this on and off, hopefully I will have a better version out soon.
I use it mainly as a way to access programmatically the main taxonomy of an ontology and its classes (not the properties yet).
I'm working on this on and off, hopefully I will have a better version out soon.
# EXAMPLE: LOADING AND QUERYING the FOAF ONTOLOGY In [1]: from onto_inspector import * In [2]: onto = OntoInspector("http://xmlns.com/foaf/spec/20100809.rdf") In [3]: onto.toplayer Out[3]: [rdflib.URIRef('http://xmlns.com/foaf/0.1/Agent'), rdflib.URIRef('http://www.w3.org/2000/01/rdf-schema#Class'), rdflib.URIRef('http://www.w3.org/2004/02/skos/core#Concept'), rdflib.URIRef('http://xmlns.com/foaf/0.1/Document'), rdflib.URIRef('http://xmlns.com/foaf/0.1/LabelProperty'), rdflib.URIRef('http://www.w3.org/2000/01/rdf-schema#Literal'), rdflib.URIRef('http://www.w3.org/2000/10/swap/pim/contact#Person'), rdflib.URIRef('http://xmlns.com/foaf/0.1/Project'), rdflib.URIRef('http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing'), rdflib.URIRef('http://www.w3.org/2002/07/owl#Thing')] In [4]: onto.printTree() foaf:Agent ----foaf:Group ----foaf:Organization ----foaf:Person rdfs:Class http://www.w3.org/2004/02/skos/core#Concept foaf:Document ----foaf:Image ----foaf:PersonalProfileDocument foaf:LabelProperty rdfs:Literal http://www.w3.org/2000/10/swap/pim/contact#Person ----foaf:Person foaf:Project http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing ----foaf:Person owl:Thing ----foaf:OnlineAccount --------foaf:OnlineChatAccount --------foaf:OnlineEcommerceAccount --------foaf:OnlineGamingAccount In [5]: document = onto.find_class_byname("document") In [6]: document Out[6]: [rdflib.URIRef('http://xmlns.com/foaf/0.1/Document'), rdflib.URIRef('http://xmlns.com/foaf/0.1/PersonalProfileDocument')] In [7]: document = document[0] In [8]: document Out[8]: rdflib.URIRef('http://xmlns.com/foaf/0.1/Document') In [9]: onto.get_classAllSubs(document) Out[9]: [rdflib.URIRef('http://xmlns.com/foaf/0.1/Image'), rdflib.URIRef('http://xmlns.com/foaf/0.1/PersonalProfileDocument')] In [10]: onto.get_classAllSupers(document) Out[10]: [] In [11]: onto.get_classComment(document) Out[11]: rdflib.Literal('A document.', language=None, datatype=None)