Mercurial > hg > audio-features-catalogue
annotate pdfextract/writeCatalogue.py @ 1:365a37a2fb6c
added files from pdfextract directory
author | nothing@tehis.net |
---|---|
date | Mon, 25 Feb 2013 14:47:41 +0000 |
parents | |
children |
rev | line source |
---|---|
nothing@1 | 1 import rdflib, os, fnmatch, urllib2 |
nothing@1 | 2 from rdflib import Graph, RDF, RDFS, plugin, URIRef, Literal, OWL |
nothing@1 | 3 from xml.dom.minidom import parseString |
nothing@1 | 4 |
nothing@1 | 5 ns = 'http://sovarr.c4dm.eecs.qmul.ac.uk/features/' |
nothing@1 | 6 |
nothing@1 | 7 basedir = '/Users/alo/MusicOntology/features/' |
nothing@1 | 8 |
nothing@1 | 9 execfile(basedir + 'pdfextract/graphDefs.py') |
nothing@1 | 10 |
nothing@1 | 11 graph = Graph() |
nothing@1 | 12 graph.bind('af', URIRef(ns)) |
nothing@1 | 13 graph.bind('dc', URIRef('http://purl.org/dc/elements/1.1/')) |
nothing@1 | 14 graph.bind('owl', OWL) |
nothing@1 | 15 |
nothing@1 | 16 addBaseTriples(graph, ns) |
nothing@1 | 17 |
nothing@1 | 18 loadBase( graph, basedir + 'rdf/base.rdf' ) |
nothing@1 | 19 |
nothing@1 | 20 for name in os.listdir(basedir+'rdf/'): |
nothing@1 | 21 if fnmatch.fnmatch(name, 'af-*.rdf'): |
nothing@1 | 22 addTriplesFromFile(graph, basedir+'rdf/'+name, ns) |
nothing@1 | 23 |
nothing@1 | 24 compareForSimilarities(graph, ns) |
nothing@1 | 25 |
nothing@1 | 26 graph.serialize(basedir + 'af-catalogue.rdf') |
nothing@1 | 27 graph.serialize(basedir + 'af-catalogue.n3', format='n3') |