annotate 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
rev   line source
nothing@18 1 import rdflib
nothing@18 2 from rdflib import Graph, RDF, RDFS, plugin, URIRef, Literal, OWL, Namespace
nothing@18 3 from InfixOwl.InfixOwl import *
nothing@18 4
nothing@18 5 url = 'http://sovarr.c4dm.eecs.qmul.ac.uk/'
nothing@18 6 ns = Namespace(url+'vocabulary/')
nothing@18 7 basedir = '/Users/alo/MusicOntology/features/'
nothing@18 8
nothing@18 9 afcns = Namespace(url+'features/')
nothing@18 10
nothing@18 11 ontograph = Graph()
nothing@18 12
nothing@18 13 af = Namespace(url+'af/ontology/1.0#')
nothing@18 14 ontograph.bind('af', af)
nothing@18 15
nothing@18 16 dc = Namespace('http://purl.org/dc/elements/1.1/')
nothing@18 17 ontograph.bind('dc', dc)
nothing@18 18
nothing@18 19 owl = Namespace('http://www.w3.org/2002/07/owl#')
nothing@18 20 ontograph.bind('owl', owl)
nothing@18 21
nothing@18 22 xsd = Namespace('http://www.w3.org/2001/XMLSchema#')
nothing@18 23 ontograph.bind('xsd', xsd)
nothing@18 24
nothing@18 25 vs = Namespace('http://www.w3.org/2003/06/sw-vocab-status/ns#')
nothing@18 26 ontograph.bind('vs', vs)
nothing@18 27
nothing@18 28 mo = Namespace('http://purl.org/ontology/mo/')
nothing@18 29 ontograph.bind('mo', mo)
nothing@18 30
nothing@18 31 event = Namespace('http://purl.org/NET/c4dm/event.owl#')
nothing@18 32 ontograph.bind('event', event)
nothing@18 33
nothing@18 34 tl = Namespace('http://purl.org/NET/c4dm/timeline.owl#')
nothing@18 35 ontograph.bind('tl', tl)
nothing@18 36
nothing@18 37 execfile(basedir + 'rdfpy/af-ontology-defs.py')
nothing@18 38
nothing@18 39 writeHeader(
nothing@18 40 ontograph,
nothing@18 41 "The Audio Feature ontology",
nothing@18 42 "1.0",
nothing@18 43 "This ontology expresses some common concepts to represent automatically extracted features from audio signals."
nothing@18 44 )
nothing@18 45
nothing@18 46 ontograph.add((
nothing@18 47 vs['term_status'],
nothing@18 48 RDF.type,
nothing@18 49 OWL.AnnotationProperty
nothing@18 50 ))
nothing@18 51
nothing@18 52 afid = addTerm(ontograph, "Audio Feature")
nothing@18 53
nothing@18 54 addOriginalOntology(ontograph)
nothing@18 55
nothing@18 56 addBaseTriples(ontograph, basedir + 'rdfpy/writeBaseOnto.py', basedir + 'rdfonto/baseOnto.rdf')
nothing@18 57
nothing@18 58 files = {
nothing@18 59 "Timbre Toolbox": {'py': "writeTimbreToolboxOnto", 'rdf': "TimbreToolbox-onto"},
nothing@18 60 "MIR Toolbox": {'py': "writeMIRToolboxOnto", 'rdf': "MIR-onto"},
nothing@18 61 "Marsyas": {'py': "writeMarsyasOnto", 'rdf': "Marsyas-onto"}
nothing@18 62 }
nothing@18 63
nothing@18 64 for tool in files.keys():
nothing@18 65 addTriples(ontograph, basedir + 'rdfpy/' + files[tool]['py'] + '.py', basedir + 'rdfonto/' + files[tool]['rdf'] + ".rdf", tool)
nothing@18 66
nothing@18 67 serialize(ontograph, basedir + 'rdfonto/', 'af-ontology')