annotate rdfpy/writeCatalogue.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, urllib2
|
nothing@0
|
2 from rdflib import Graph, RDF, RDFS, plugin, URIRef, Literal, OWL
|
nothing@0
|
3 from xml.dom.minidom import parseString
|
nothing@0
|
4
|
nothing@0
|
5 ns = 'http://sovarr.c4dm.eecs.qmul.ac.uk/features/'
|
nothing@0
|
6
|
nothing@0
|
7 basedir = '/Users/alo/MusicOntology/features/'
|
nothing@0
|
8
|
nothing@0
|
9 execfile(basedir + 'pdfextract/graphDefs.py')
|
nothing@0
|
10
|
nothing@0
|
11 graph = Graph()
|
nothing@0
|
12 graph.bind('af', URIRef(ns))
|
nothing@0
|
13 graph.bind('dc', URIRef('http://purl.org/dc/elements/1.1/'))
|
nothing@0
|
14 graph.bind('owl', OWL)
|
nothing@0
|
15
|
nothing@0
|
16 addBaseTriples(graph, ns)
|
nothing@0
|
17
|
nothing@0
|
18 loadBase( graph, basedir + 'rdf/base.rdf' )
|
nothing@0
|
19
|
nothing@0
|
20 for name in os.listdir(basedir+'rdf/'):
|
nothing@0
|
21 if fnmatch.fnmatch(name, 'af-*.rdf'):
|
nothing@0
|
22 addTriplesFromFile(graph, basedir+'rdf/'+name, ns)
|
nothing@0
|
23
|
nothing@0
|
24 compareForSimilarities(graph, ns)
|
nothing@0
|
25
|
nothing@18
|
26 graph.serialize(basedir + 'af-catalogue-01.rdf')
|
nothing@18
|
27 graph.serialize(basedir + 'af-catalogue-01.n3', format='n3') |