A Python project for working with RDF/OWL ontologies
Project description
RDFLIb-based Python toolkit for inspecting ontologies on the Semantic Web.
Description
OntoSPy allows you to extract all the schema information from an RDFS/OWL or SKOS schema, inspect it and use it query a corresponding knowledge base.
The basic workflow is simple: load a graph instantiating the Graph class; you get back an object that lets you interrogate the RDF schema. That’s all!
The library can be used in standalone mode too.
See also: - documentation: http://ontospy.readthedocs.org/en/latest/ - source: https://github.com/lambdamusic/OntoSPy
Version
1.6 (Oct 2016)
Check the ontospy/_version.py file for more details.
Example
Import OntoSPy and instantiate the Graph object with the FOAF ontology:
In [1]: from ontospy import ontospy
In [2]: g = ontospy.Graph("http://xmlns.com/foaf/spec/20100809.rdf")
----------
Loaded 631 triples from <http://xmlns.com/foaf/spec/20100809.rdf>
started scanning...
----------
Ontologies found: 1
Classes found...: 14
Properties found: 67
Annotation......: 7
Datatype........: 26
Object..........: 34
In [3]: g.toplayer
Out[3]:
[<Class *http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing*>,
<Class *http://xmlns.com/foaf/0.1/Agent*>,
<Class *http://xmlns.com/foaf/0.1/Document*>,
<Class *http://xmlns.com/foaf/0.1/LabelProperty*>,
<Class *http://xmlns.com/foaf/0.1/OnlineAccount*>,
<Class *http://xmlns.com/foaf/0.1/Project*>]
In [4]: g.printClassTree()
[1] http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing
[12] ----foaf:Person
[2] foaf:Agent
[4] ----foaf:Group
[11] ----foaf:Organization
[12] ----foaf:Person
[3] foaf:Document
[5] ----foaf:Image
[13] ----foaf:PersonalProfileDocument
[6] foaf:LabelProperty
[7] foaf:OnlineAccount
[8] ----foaf:OnlineChatAccount
[9] ----foaf:OnlineEcommerceAccount
[10] ----foaf:OnlineGamingAccount
[14] foaf:Project
In [5]: doc = g.getClass(3)
In [6]: doc
Out[6]: <Class *http://xmlns.com/foaf/0.1/Document*>
In [7]: doc.describe()
Parents......: 0
Children.....: 2
Ancestors....: 0
Descendants..: 2
Domain of....: 3
Range of.....: 12
Instances....: 0
http://xmlns.com/foaf/0.1/Document
=> http://www.w3.org/2000/01/rdf-schema#comment
.... A document.
=> http://www.w3.org/2002/07/owl#disjointWith
.... http://xmlns.com/foaf/0.1/Project
=> http://www.w3.org/2000/01/rdf-schema#isDefinedBy
.... http://xmlns.com/foaf/0.1/
=> http://www.w3.org/2002/07/owl#disjointWith
.... http://xmlns.com/foaf/0.1/Organization
=> http://www.w3.org/2000/01/rdf-schema#label
.... Document
=> http://www.w3.org/2002/07/owl#equivalentClass
.... http://schema.org/CreativeWork
=> http://www.w3.org/2003/06/sw-vocab-status/ns#term_status
.... stable
=> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
.... http://www.w3.org/2000/01/rdf-schema#Class
=> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
.... http://www.w3.org/2002/07/owl#Class
In [8]: doc.descendants()
Out[8]:
[<Class *http://xmlns.com/foaf/0.1/Image*>,
<Class *http://xmlns.com/foaf/0.1/PersonalProfileDocument*>]
In [9]: for c in doc.descendants():
c.describe()
Parents......: 1
Children.....: 0
Ancestors....: 1
Descendants..: 0
Domain of....: 2
Range of.....: 3
Instances....: 0
http://xmlns.com/foaf/0.1/Image
=> http://www.w3.org/2000/01/rdf-schema#comment
.... An image.
=> http://www.w3.org/2003/06/sw-vocab-status/ns#term_status
.... stable
=> http://www.w3.org/2002/07/owl#equivalentClass
.... http://schema.org/ImageObject
=> http://www.w3.org/2000/01/rdf-schema#subClassOf
.... http://xmlns.com/foaf/0.1/Document
=> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
.... http://www.w3.org/2002/07/owl#Class
=> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
.... http://www.w3.org/2000/01/rdf-schema#Class
=> http://www.w3.org/2000/01/rdf-schema#isDefinedBy
.... http://xmlns.com/foaf/0.1/
=> http://www.w3.org/2000/01/rdf-schema#label
.... Image
Parents......: 1
Children.....: 0
Ancestors....: 1
Descendants..: 0
Domain of....: 0
Range of.....: 0
Instances....: 0
http://xmlns.com/foaf/0.1/PersonalProfileDocument
=> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
.... http://www.w3.org/2002/07/owl#Class
=> http://www.w3.org/2000/01/rdf-schema#label
.... PersonalProfileDocument
=> http://www.w3.org/2000/01/rdf-schema#subClassOf
.... http://xmlns.com/foaf/0.1/Document
=> http://www.w3.org/2003/06/sw-vocab-status/ns#term_status
.... testing
=> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
.... http://www.w3.org/2000/01/rdf-schema#Class
=> http://www.w3.org/2000/01/rdf-schema#comment
.... A personal profile RDF document.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ontospy-1.6.0.tar.gz.
File metadata
- Download URL: ontospy-1.6.0.tar.gz
- Upload date:
- Size: 842.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39917c50a35ee442422919e73ded06cef25a6b07f20e35b4d4192c3f2507f5eb
|
|
| MD5 |
5f4cff78b3bf1f4d0f7b8d5adea616bc
|
|
| BLAKE2b-256 |
d2555a244cae1b46862cbe6b0b39d55fc0b79c83f318233b8126a8edc451775c
|
File details
Details for the file ontospy-1.6.0-py2.py3-none-any.whl.
File metadata
- Download URL: ontospy-1.6.0-py2.py3-none-any.whl
- Upload date:
- Size: 883.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
776d86188e03209c128cc8b8443d36bda220602fea93d6b18f054813844d5199
|
|
| MD5 |
033b556d342fb3564dc911853212179b
|
|
| BLAKE2b-256 |
7a7f922c4f129d649b7910fb92f7fbd674d40d6f3d6ab3558d8e6ee289a0e19a
|
File details
Details for the file ontospy-1.6.0-py2.7.egg.
File metadata
- Download URL: ontospy-1.6.0-py2.7.egg
- Upload date:
- Size: 944.2 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
454bbd4d4414232d2102b7439a9486f91d7753b021b25080e2da88adfad3e80a
|
|
| MD5 |
f7b21d1740fd5c4e84606e87dd0e95e6
|
|
| BLAKE2b-256 |
12c7a67e7fb125e747c1e344c256cdd77da888597dfc97a93977af3d9e496a31
|