Alex J.
Alex J.

Reputation: 337

Can MarkLogic use inference over embedded triples?

Will MarkLogic apply reasoning when triples are queried using sem:sparql against a selected set of stores?

Upvotes: 3

Views: 139

Answers (2)

Ankita Bhowmik
Ankita Bhowmik

Reputation: 463

If you have established some relationships among triples and try to fetch results using a ruleset then it will Marklogic definitely apply reasoning while performing search.

For Example i created the following triple

 PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
 PREFIX prod: <http://www.example.com/products/>
 PREFIX ex: <http://www.example.com/>

 INSERT DATA
 {

   prod:1001 rdf:type ex:Apple;

   prod:1002 rdf:type ex:Fruit;

 }

Now if you search for all the subjects which are of type apple it will only give you prod:1002

And now establish a relationship among them as

 PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
 PREFIX ex: <http://www.example.com/>

 INSERT DATA
 {

   ex:Apple rdfs:subClassOf ex:Fruit .

 }

and set the default ruleset of your database to subClassOf.rules and then run the same query

 PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
 PREFIX ex: <http://www.example.com/>

 SELECT ?product
 WHERE
 {
  ?product rdf:type ex:Fruit 
 }

Now it will return you both prod:1001 and prod:1002

also for further details you can visit the marklogic documentation which has a very good description of inferencing. https://developer.marklogic.com/features/semantics/inference-examples

Upvotes: 1

Dave Cassel
Dave Cassel

Reputation: 8422

Alex, take a look at Choosing Rulesets for Queries. You'll see an example there where a SPARQL query is applied to a store of triples resulting from applying two sets of inference rules to a set of triples. If you modify that example slightly, it shows a SPARQL query applied to running inference on all triples in the triples index, which includes embedded triples.

xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics" 
  at "/MarkLogic/semantics.xqy";

PREFIX skos: <http://www.w3.org/2004/02/skos/core#Concept/>

sem:sparql("select * { ?c a skos:Concept; rdfs:label ?l }",(),(),
  sem:ruleset-store(
    ("subClassOf.rules", "subPropertyOf.rules"),
    sem:store()
  )
)

Upvotes: 4

Related Questions