RDFTensor (version 1.3)

tnsr2trp: sparse tensor to triples

Description

convert a sparse tensor (e.g. created using getTensor) to set of triples.

Usage

tnsr2trp(tnsr)

Arguments

tnsr

a sparse tensor (e.g. created using getTensor)

Value

a matrix of three columns containing the triples

See Also

getTnsrijk getTensor

Examples

Run this code
# NOT RUN {
trp=rbind(
    cbind('Alex',  'loves', 'Don'),
    cbind('Alex',  'loves', 'Elly'),
    cbind('Alex',  'hates', 'Bob'),
    cbind('Don',   'loves', 'Alex'),
    cbind('Don',   'hates', 'Chris'),
    cbind('Chris', 'hates', 'Bob'),
    cbind('Bob',   'hates', 'Chris'),
    cbind('Elly',  'hates', 'Chris'),
    cbind('Elly',  'hates', 'Bob'),
    cbind('Elly',  'loves', 'Alex')
    )
######
# form tensor as a set of frontal slices (Predicate mode)
    tnsr=getTensor(trp)
    trp_=tnsr2trp(tnsr)
    #print(any(! paste(trp_[,1],trp_[,2],trp_[,3]) %in% paste(trp[,1],trp[,2],trp[,3])))
    #print(any(! paste(trp[,1],trp[,2],trp[,3]) %in% paste(trp_[,1],trp_[,2],trp_[,3])))
# }

Run the code above in your browser using DataLab