#!/usr/bin/python """Eep RDF API: Inference Engine""" __author__ = 'Sean B. Palmer' __license__ = 'Copyright (C) 2001 Sean B. Palmer. GNU GPL 2' import eep, query def rule(ante, cons): return eep.parse(ante), eep.parse(cons) def filter(r, store): """Give the results only - don't add to the store.""" qres, result = query.xtquery(r[0], store), [] for res in qres: int = [] for t in r[1]: t = t[:] for p in (0, 1, 2): if (t[p].t == 'Univar') and (t[p].r in res[1].keys()): t[p] = eep.Article(res[1][t[p].r]) int.append(t) result.append(int) return result def apply(rule, store, NTriples=0): for r in filter(rule, store): store.extend([x for x in r]) return [store, eep.serialize(store)][NTriples] if __name__=="__main__": print __doc__