reify
index
/devel/WWW/2000/10/swap/reify.py

Functions to reify and dereify a graph.
These functions should be perfect inverses of each other.
 
The strategy used is different from that of the reifier
in notation3.py, that tries to reify what it outputs.
This simply puts the reification into the sink given,
or a new one, depending on the function called.
$Id: reify.html,v 1.1 2004/10/28 17:41:59 timbl Exp $

 
Modules
            
diag
uripath
 
Functions
            
dereification(x, f, sink, bnodes={}, xList=[])
dereification_old(formula, sink)
dereify(formula, sink=None, xList=[])
#### Alternative method
# Shortcuts are too messy and don't work with lists
dereify_old(formula)
flatten(formula)
Flatten a formula
 
This will minimally change a formula to make it valid RDF
flattening a flattened formula should thus be the unity
reification(formula, sink, bnodes={})
Create description of formula in sink
 
Returns bNode corresponding to the reification
reify(formula)
Reify a formula
 
Returns an RDF formula with the same semantics
as the given formula
typeDispatch(typeDict, term, optional=None)
Dispatch which function to call based on type
 
This can be less ugly that if statements, if done right
unflatten(formula, sink=None)
Undo the effects of the flatten function.
 
Note that this still requires helper methods scattered throughout the
Term heriarchy. 
 
Our life is made much more difficult by the necessity of removing all
triples that have been dereified --- this required a modification to dereification()
 
Data
             ALL4 = (0, 1, 2, 3)
CONTEXT = 0
OBJ = 3
PARTS = (1, 2, 3)
PRED = 1
SUBJ = 2
__file__ = './reify.pyc'
__name__ = 'reify'
owlOneOf = 'http://www.w3.org/2002/07/owl#oneOf'
reifyNS = 'http://www.w3.org/2004/06/rei#'