Skip to content

Instantly share code, notes, and snippets.

@wolph
Created October 25, 2012 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolph/3952582 to your computer and use it in GitHub Desktop.
Save wolph/3952582 to your computer and use it in GitHub Desktop.
Ontology Engineering Sesame Wrapper
#!/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