I created an RDF file where images are stored in nodes as matrices. However when I try to read them I cannot get the matrix form: For example
from rflib import Literal
mm = np.random.normal(0,1,(3,3))
L = Literal(mm)
it is very easy to get the matrix back with L.value
In [494]: L
Out[494]: rdflib.term.Literal(u'[[-1.39304728 0.39093531 0.88042378]\n [ 0.22605682 0.56064787 -0.75176713]\n [ 0.57021203 0.31796492 -0.53303191]]')
In [495]: L.value
Out[495]:
array([[-1.39304728, 0.39093531, 0.88042378],
[ 0.22605682, 0.56064787, -0.75176713],
[ 0.57021203, 0.31796492, -0.53303191]])
However when I execute a SPARQL stored in image_nodes I get:
In [501]: res = [q for q in image_nodes]
In [502]: res[0][0]
Out[502]: rdflib.term.Literal(u'[[ 0. 0. 0. ..., 0. 0. 0.]\n [ 0. 0. 0. ..., 0. 0. 0.]\n [ 0. 0. 0. ..., 0. 0. 0.]\n ..., \n [ 0. 0. 0. ..., 0. 0. 0.]\n [ 0. 0. 0. ..., 0. 0. 0.]\n [ 0. 0. 0. ..., 0. 0. 0.]]')
In [503]: (res[0][0]).value
Out[503]: u'[[ 0. 0. 0. ..., 0. 0. 0.]\n [ 0. 0. 0. ..., 0. 0. 0.]\n [ 0. 0. 0. ..., 0. 0. 0.]\n ..., \n [ 0. 0. 0. ..., 0. 0. 0.]\n [ 0. 0. 0. ..., 0. 0. 0.]\n [ 0. 0. 0. ..., 0. 0. 0.]]'
Why cant I get the matrix format this time? This is in unicode and very resistant to any transformation. Thanks