This is general overview of the Eep API, as well as the best documentation for it that you're going to find.
This is the main base of the API - it contains the extremely important Article class, which is the basic atom of all RDF stores - doing work such as parsing NTriples, serializing lists, and generally being rather helpful.
Article(s)
>>> a = Article('<#x>')
>>> a
<#x>
>>> a.repr
'<#x>'
>>> a.type
'URI'
>>> a.val
'#x'
This module also contains the following functions:-
parse(s, [t])serialize(triples)contains(triple, store)
>>> eep.contains(eep.parse('<#x> _:y "z" .')[0],
eep.parse('?p _:q <#s> .\n<#x> _:y "z" .'))
1
>>> eep.contains(eep.parse('<#l> _:m "n" .')[0],
eep.parse('?p _:q <#s> .\n<#x> _:y "z" .'))
0
>>>
>>> eep.parse('?p _:q <#s> .\n<#x> _:y "z" .')
[[?p, _:q, <#s>], [<#x>, _:y, "z"]]
>>> eep.serialize(eep.parse('?p _:q <#s> .\n<#x> _:y "z" .'))
'?p _:q <#s> .\n<#x> _:y "z" .'
>>> for triple in eep.parse('?p _:q <#s> .\n<#x> _:y "z" .'):
for term in triple: print term.type, term.val, term.repr
Univar p ?p
Exivar q _:q
URI #s <#s>
URI #x <#x>
Exivar y _:y
Literal z "z"
>>>
Note that eep.parse always returns a store! To get one triple, use eep.parse(s)[0].
This is the query module for Eep. It has simple and complex querying functionalities.
squery(q, fs)rquery(q, fs)
>>> query.squery(eep.parse('?x <#y> ?x .')[0],
eep.parse('<#x> <#y> <#z> .'))
[[<#x>, <#y>, <#z>]]
>>> query.rquery(eep.parse('?x <#y> ?x .')[0],
eep.parse('<#x> <#y> <#z> .'))
[]
Since "<#x>" is not the same as "<#z>", rquery does not match it.
tquery(qs, fs, [NTriples])
>>> print query.tquery(eep.parse('?x <#sonOf> ?y .\n?y <#sonOf> ?z .'),
eep.parse("""<#Bob> <#sonOf> <#Fred> .
<#Fred> <#sonOf> <#John> .
<#John> <#sonOf> <#Wayne> ."""), 1)
<#Bob> <#sonOf> <#Fred> .
<#Fred> <#sonOf> <#John> .
<#Fred> <#sonOf> <#John> .
<#John> <#sonOf> <#Wayne> .
The test file for this module is querytest.py.
This is an inference engine.
>>> store = eep.parse("""<#Bob> <#sonOf> <#Fred> .
<#Fred> <#sonOf> <#John> .
<#John> <#sonOf> <#Wayne> .""")
>>> r = infer.rule('?x <#sonOf> ?y .\n?y <#sonOf> ?z .', # log:implies
'?x <#grandchildOf> ?z .')
>>> for p in infer.filter(r, store): print eep.serialize(p)
<#Bob> <#grandchildOf> <#John> .
<#Fred> <#grandchildOf> <#Wayne> .
Sean B. Palmer