annotate rdfpy/writeCatalogue.py @ 1:365a37a2fb6c
added files from pdfextract directory
author |
nothing@tehis.net |
date |
Mon, 25 Feb 2013 14:47:41 +0000 |
parents |
62d2c72e4223 |
children |
d5012016bf64 |
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@0
|
26 graph.serialize(basedir + 'af-catalogue.rdf')
|
nothing@0
|
27 graph.serialize(basedir + 'af-catalogue.n3', format='n3') |