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

query.unify.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.

There is a newer version: 4.6.1
Show newest version
#
# Factorize an OWL RDF graph in such a way that different bnodes
# representing the same AST OWL expression are collapsed into one bnode.
#
# Olivier Corby - Wimmics INRIA I3S - 2014
#
prefix sp:  .
delete { 
    ?x ?p ?b 
}
insert { 
    ?x ?p ?r 
    ?b sp:isReplacedBy ?r
}
where {
    # select one bnode ?r for all bnodes ?b that represent the same expresssion 
    # ?exp is computed by a transformation st:hash based on st:turtle
    # except that RDF lists are ordered
    
    {select (sample(?b) as ?r) ?exp where {

        values ?p { 
            owl:allValuesFrom owl:someValuesFrom owl:onClass
            owl:intersectionOf owl:unionOf owl:equivalentClass 
            owl:complementOf owl:disjointWith  
            rdfs:subClassOf rdfs:domain rdfs:range rdf:type rdf:first
        }

        ?x ?p ?b . filter isBlank(?b)
      }
      group by (st:apply-templates-with(st:hash, ?b) as ?exp)
      having (count(?b) > 1)
    }
                 
    values ?p { 
        owl:allValuesFrom owl:someValuesFrom owl:onClass
        owl:intersectionOf owl:unionOf owl:equivalentClass
        owl:complementOf owl:disjointWith  
        rdfs:subClassOf rdf:type rdf:first
    }
    
    ?x ?p ?b . filter isBlank(?b) 
                                 
    filter(?b != ?r)
    filter(st:apply-templates-with(st:hash, ?b) = ?exp)                
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy