All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sttl.d3.profile.rq Maven / Gradle / Ivy

Go to download

Corese is a Semantic Web Factory (triple store and SPARQL endpoint) implementing RDF, RDFS, SPARQL 1.1 Query and Update.

The newest version!
template st:profile {}
where {}

function us:start() {
    set(?map = xt:map())
}

function us:nodePropertyList() {
    coalesce(st:get(st:nodePropertyList), us:defaultNodePropertyList())
}

function us:defaultNodePropertyList() {
    let (?list = @(("bg_image" st:img) ("domain" rdfs:domain) ("range" rdfs:range) ("property" us:value))) {
        ?list
    }
}


function us:kind(?s) {
    coalesce (st:getgroup(?s), 
        if (isURI(?s), "uri", 
        if (isBlank(?s), "bnode", "literal")))
}

function us:record(?s) {
   xt:set(?map, ?s, coalesce(xt:get(?map, ?s), concat('n', xt:size(?map))))
}

function us:triple(?s, ?p, ?o) {
    us:record(?s) ;
    us:record(?o) 
}

function us:process(?s, ?p, ?o) {
    if (?p = rdfs:domain || ?p = rdfs:range,  us:store(?s, ?p, ?o), true)
}

function us:store(?s, ?p, ?o) {
    st:cset(?p, ?s, coalesce(concat(st:cget(?p, ?s), " ", st:turtle(?o)), st:turtle(?o)))
}
 

function us:get(?s) {
    xt:get(?map, ?s)
}

function us:getNodes() {
    return (?map)
}

function us:declare(?fun) {
    set(?pretty = ?fun)
}

function us:label(?s) {
    us:pretty(coalesce(st:cget(st:label, ?s), ?s))
}

function us:pretty(?s) {
    if (isBlank(?s), "",
    if (isLiteral(?s), us:literal(?s), us:uri(?s)))
}

function us:uri(?u) {
    if (contains(?u, ".jpg"), us:shorten(st:turtle(?u, true)), st:turtle(?u, true, true))
}

function us:shorten(?l) {
    let (?s = if (strlen(?l) > 50, concat(substr(?l, 1, 50), "..."), ?l)) { ?s }
}

function us:literal(?l) {
    let (?s = us:shorten(?l)) {
        replace(replace(replace(str(?s), "\n", ""), "\"", "'"), "\r", "")
    }
}

function us:nodeClass(?s) {
    coalesce(st:getclass(?s), 
        if (isLiteral(?s), "literal", if (isURI(?s), "uri", "bnode") ) )
} 

function us:prefix(?p) {
    if (strstarts(?p, rdf:),  "rdf", 
    if (strstarts(?p, rdfs:), "rdfs", 
    if (strstarts(?p, owl:),  "owl", 
    if (strstarts(?p, foaf:), "foaf", 
    if (strstarts(?p, skos:), "skos", 
    if (strstarts(?p, dc:),   "dc", 
    "default") ) ))))
}

function us:edgeClass(?g, ?p) {
    coalesce(st:getclass(?g), us:prefix(?p))
}

function us:edgeGroup(?g, ?p) {
    coalesce(st:getgroup(?g), us:prefix(?p))
}

function us:plist(?list) {
    reduce(lambda(?a, ?b) {concat(?a, ", " , ?b) }, 
        maplist(lambda(?name) { st:format("\"%s\"", us:pname(?name)) }, ?list)
    )
}

function us:pname(?x) {
    if (isURI(?x), st:turtle(?x), ?x)
}
  




© 2015 - 2025 Weber Informatics LLC | Privacy Policy