Mercurial > hg > audio-features-catalogue
diff rdfpy/af-ontology.py @ 18:d5012016bf64 tip
added rdfpy and rdfonto directories
author | nothing@tehis.net |
---|---|
date | Tue, 23 Apr 2013 11:49:20 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rdfpy/af-ontology.py Tue Apr 23 11:49:20 2013 +0100 @@ -0,0 +1,67 @@ +import rdflib +from rdflib import Graph, RDF, RDFS, plugin, URIRef, Literal, OWL, Namespace +from InfixOwl.InfixOwl import * + +url = 'http://sovarr.c4dm.eecs.qmul.ac.uk/' +ns = Namespace(url+'vocabulary/') +basedir = '/Users/alo/MusicOntology/features/' + +afcns = Namespace(url+'features/') + +ontograph = Graph() + +af = Namespace(url+'af/ontology/1.0#') +ontograph.bind('af', af) + +dc = Namespace('http://purl.org/dc/elements/1.1/') +ontograph.bind('dc', dc) + +owl = Namespace('http://www.w3.org/2002/07/owl#') +ontograph.bind('owl', owl) + +xsd = Namespace('http://www.w3.org/2001/XMLSchema#') +ontograph.bind('xsd', xsd) + +vs = Namespace('http://www.w3.org/2003/06/sw-vocab-status/ns#') +ontograph.bind('vs', vs) + +mo = Namespace('http://purl.org/ontology/mo/') +ontograph.bind('mo', mo) + +event = Namespace('http://purl.org/NET/c4dm/event.owl#') +ontograph.bind('event', event) + +tl = Namespace('http://purl.org/NET/c4dm/timeline.owl#') +ontograph.bind('tl', tl) + +execfile(basedir + 'rdfpy/af-ontology-defs.py') + +writeHeader( + ontograph, + "The Audio Feature ontology", + "1.0", + "This ontology expresses some common concepts to represent automatically extracted features from audio signals." +) + +ontograph.add(( + vs['term_status'], + RDF.type, + OWL.AnnotationProperty +)) + +afid = addTerm(ontograph, "Audio Feature") + +addOriginalOntology(ontograph) + +addBaseTriples(ontograph, basedir + 'rdfpy/writeBaseOnto.py', basedir + 'rdfonto/baseOnto.rdf') + +files = { + "Timbre Toolbox": {'py': "writeTimbreToolboxOnto", 'rdf': "TimbreToolbox-onto"}, + "MIR Toolbox": {'py': "writeMIRToolboxOnto", 'rdf': "MIR-onto"}, + "Marsyas": {'py': "writeMarsyasOnto", 'rdf': "Marsyas-onto"} +} + +for tool in files.keys(): + addTriples(ontograph, basedir + 'rdfpy/' + files[tool]['py'] + '.py', basedir + 'rdfonto/' + files[tool]['rdf'] + ".rdf", tool) + +serialize(ontograph, basedir + 'rdfonto/', 'af-ontology') \ No newline at end of file