nothing@0: import rdflib, os, fnmatch nothing@0: from rdflib import Graph, RDF, RDFS, plugin, URIRef, Literal, OWL nothing@0: nothing@0: basedir = '/Users/alo/MusicOntology/features/' nothing@0: nothing@0: local = 'http://sovarr.c4dm.eecs.qmul.ac.uk/features/' nothing@0: nothing@0: for name in os.listdir(basedir+'rdf/'): nothing@0: if fnmatch.fnmatch(name, '*.rdf'): nothing@0: graph = Graph() nothing@0: graph.parse(basedir+'rdf/'+name) nothing@0: graph.bind(name[3:-4], URIRef('file://'+basedir+"rdf/")) nothing@0: graph.bind('owl', 'http://www.w3.org/2002/07/owl#') nothing@0: nothing@0: graph.serialize(basedir+'rdfn3/'+name.split('.')[0]+'.n3', format='n3') nothing@0: print "Serialized graph to " + basedir+'rdfn3/'+name.split('.')[0]+'.n3'