view service/reasoning/oneShot @ 47:0448fbd96a31

scan more input files. oneshot and immediate update features. Ignore-this: bb6c89f44478d27456319b94db2ec81a
author drewp@bigasterisk.com
date Mon, 31 Dec 2012 00:47:12 -0800
parents
children 745eff67ad40
line wrap: on
line source

#!/usr/bin/python
"""
send a statement to the reasoning server for one update cycle. Args
are s/p/o in n3 notation, with many prefixes predefined here.
"""
import sys, restkit
s, p, o = sys.argv[1:]

prefixes = {
'room' : 'http://projects.bigasterisk.com/room/',
    }

def expand(term):
    if ':' not in term:
        return term
    left, right = term.split(':', 1)
    if left in prefixes:
        return '<%s%s>' % (prefixes[left], right)
    return term

stmt = '%s %s %s .' % (expand(s), expand(p), expand(o))
print "Sending: %s" % stmt

reasoning = restkit.Resource("http://bang:9071/")
reasoning.post("oneShot",
               headers={"content-type": "text/n3"},
               payload=stmt)