Search code examples
rdfsemantic-webontology

How to extract/get all the terms(classes/properties) in an ontology


i have a data set of different ontologies and i want to extract/get all the classes, properties and any other thing that i can get out of ontology. Is there any method or library available for doing that as there are many ontologies and can't do it manually. Later i need to store that all that data in an excel sheet. Any help in that regard will be appreciated. Thanks


Solution

  • You can install a SPARQL endpoint such as Virtuoso Open Source Edition and upload the data from there:

    1. Download and install Virtuoso Open Source Edition
    2. import your RDF data into it. For example, you can download the DBpedia ontology, unpack it and upload dbpedia_2014.owl into a new graph in your SPARQL endpoint.
    3. If you have configured graph security (should be disabled by default), give your user read rights to the graph. For example, to make the graph public, execute DB.DBA.RDF_GRAPH_USER_PERMS_SET ('mygraph', 'nobody', 1); as ISQL.

    Now you can pose any kind of SPARQL query, such as:

    A list of classes can be fetched with: select * {?s a owl:Class.} if they are explicitly modelled as such, select * {{?s a owl:Class.} UNION {?s rdfs:subClassOf ?x.}} otherwise.

    Analogously, a list of properties can be queried with select * {?s a rdf:Property.}, respectively select * {{?s a rdf:Property.} UNION {?s a owl:ObjectProperty.} UNION {?s a owl:DatatypeProperty.}}.

    If you just want a list of classes and properties, you can also use Protégé, which is much easier to set up.