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