nothing@18: import rdflib nothing@18: from rdflib import Graph, RDF, RDFS, plugin, URIRef, Literal, OWL, Namespace nothing@18: from InfixOwl.InfixOwl import * nothing@18: nothing@18: url = 'http://sovarr.c4dm.eecs.qmul.ac.uk/' nothing@18: ns = Namespace(url+'vocabulary/') nothing@18: basedir = '/Users/alo/MusicOntology/features/' nothing@18: nothing@18: afcns = Namespace(url+'features/') nothing@18: nothing@18: ontograph = Graph() nothing@18: nothing@18: af = Namespace(url+'af/ontology/1.0#') nothing@18: ontograph.bind('af', af) nothing@18: nothing@18: dc = Namespace('http://purl.org/dc/elements/1.1/') nothing@18: ontograph.bind('dc', dc) nothing@18: nothing@18: owl = Namespace('http://www.w3.org/2002/07/owl#') nothing@18: ontograph.bind('owl', owl) nothing@18: nothing@18: xsd = Namespace('http://www.w3.org/2001/XMLSchema#') nothing@18: ontograph.bind('xsd', xsd) nothing@18: nothing@18: vs = Namespace('http://www.w3.org/2003/06/sw-vocab-status/ns#') nothing@18: ontograph.bind('vs', vs) nothing@18: nothing@18: mo = Namespace('http://purl.org/ontology/mo/') nothing@18: ontograph.bind('mo', mo) nothing@18: nothing@18: event = Namespace('http://purl.org/NET/c4dm/event.owl#') nothing@18: ontograph.bind('event', event) nothing@18: nothing@18: tl = Namespace('http://purl.org/NET/c4dm/timeline.owl#') nothing@18: ontograph.bind('tl', tl) nothing@18: nothing@18: execfile(basedir + 'rdfpy/af-ontology-defs.py') nothing@18: nothing@18: writeHeader( nothing@18: ontograph, nothing@18: "The Audio Feature ontology", nothing@18: "1.0", nothing@18: "This ontology expresses some common concepts to represent automatically extracted features from audio signals." nothing@18: ) nothing@18: nothing@18: ontograph.add(( nothing@18: vs['term_status'], nothing@18: RDF.type, nothing@18: OWL.AnnotationProperty nothing@18: )) nothing@18: nothing@18: afid = addTerm(ontograph, "Audio Feature") nothing@18: nothing@18: addOriginalOntology(ontograph) nothing@18: nothing@18: addBaseTriples(ontograph, basedir + 'rdfpy/writeBaseOnto.py', basedir + 'rdfonto/baseOnto.rdf') nothing@18: nothing@18: files = { nothing@18: "Timbre Toolbox": {'py': "writeTimbreToolboxOnto", 'rdf': "TimbreToolbox-onto"}, nothing@18: "MIR Toolbox": {'py': "writeMIRToolboxOnto", 'rdf': "MIR-onto"}, nothing@18: "Marsyas": {'py': "writeMarsyasOnto", 'rdf': "Marsyas-onto"} nothing@18: } nothing@18: nothing@18: for tool in files.keys(): nothing@18: addTriples(ontograph, basedir + 'rdfpy/' + files[tool]['py'] + '.py', basedir + 'rdfonto/' + files[tool]['rdf'] + ".rdf", tool) nothing@18: nothing@18: serialize(ontograph, basedir + 'rdfonto/', 'af-ontology')