annotate rdfpy/convertXMLtoN3.py @ 18:d5012016bf64
tip
added rdfpy and rdfonto directories
author |
nothing@tehis.net |
date |
Tue, 23 Apr 2013 11:49:20 +0100 |
parents |
62d2c72e4223 |
children |
|
rev |
line source |
nothing@0
|
1 import rdflib, os, fnmatch
|
nothing@0
|
2 from rdflib import Graph, RDF, RDFS, plugin, URIRef, Literal, OWL
|
nothing@0
|
3
|
nothing@0
|
4 basedir = '/Users/alo/MusicOntology/features/'
|
nothing@0
|
5
|
nothing@0
|
6 local = 'http://sovarr.c4dm.eecs.qmul.ac.uk/features/'
|
nothing@0
|
7
|
nothing@0
|
8 for name in os.listdir(basedir+'rdf/'):
|
nothing@0
|
9 if fnmatch.fnmatch(name, '*.rdf'):
|
nothing@0
|
10 graph = Graph()
|
nothing@0
|
11 graph.parse(basedir+'rdf/'+name)
|
nothing@0
|
12 graph.bind(name[3:-4], URIRef('file://'+basedir+"rdf/"))
|
nothing@0
|
13 graph.bind('owl', 'http://www.w3.org/2002/07/owl#')
|
nothing@0
|
14
|
nothing@0
|
15 graph.serialize(basedir+'rdfn3/'+name.split('.')[0]+'.n3', format='n3')
|
nothing@0
|
16 print "Serialized graph to " + basedir+'rdfn3/'+name.split('.')[0]+'.n3' |