Created
October 25, 2012 13:36
-
-
Save wolph/3952582 to your computer and use it in GitHub Desktop.
Ontology Engineering Sesame Wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
import subprocess | |
import fileinput | |
os.chdir(os.path.dirname(__file__)) | |
process = subprocess.Popen( | |
['/bin/sh', 'openrdf-sesame-2.6.9/bin/console.sh'], | |
stdin=subprocess.PIPE, | |
stdout=subprocess.PIPE, | |
stderr=subprocess.PIPE, | |
) | |
if not sys.argv[1:]: | |
print >>sys.stderr, 'Trying to read from stdin' | |
prefix = ''' | |
connect "dogfood test set". | |
open r. | |
set queryPrefix=true. | |
load "dogfood test set/iswc-2006-complete.rdf" . | |
load "dogfood test set/iswc-2008-complete.rdf" . | |
load "dogfood test set/iswc-2009-complete.rdf" . | |
load "dogfood test set/iswc-2010-complete.rdf" . | |
load "dogfood test set/www-2007-complete.rdf" . | |
load "dogfood test set/www-2008-complete.rdf" . | |
load "dogfood test set/www-2009-complete.rdf" . | |
load "dogfood test set/www-2010-complete.rdf" . | |
sparql | |
''' | |
query = '\n'.join(fileinput.input()) | |
suffix = ''' | |
. | |
exit. | |
''' | |
output = process.communicate(input=prefix + query + suffix) | |
print >>sys.stderr, '\n'.join(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment