inference - Inferencing in embedded triples of Marklogic -


i have following 2 documents. 1 document has data:

<content>   <sem:triples xmlns:sem="http://marklogic.com/semantics">     <sem:triple>       <sem:subject>http://sector#basic_materials</sem:subject>       <sem:predicate>http://relationship#istrbceconomicsectorof</sem:predicate>       <sem:object>http://company#cst_mining_group_limited</sem:object>     </sem:triple>   </sem:triples>   <analystname>henrik christiansson</analystname>   <documentformat>pdf</documentformat> </content> 

and document has following data:

<content>   <sem:triples xmlns:sem="http://marklogic.com/semantics">     <sem:triple>       <sem:triple>         <sem:subject>http://sector#energy_-_fossil_fuels</sem:subject>         <sem:predicate>http://relationship#istrbceconomicsectorof</sem:predicate>         <sem:object>http://company#bodycote_plc</sem:object>       </sem:triple>     </sem:triple>   </sem:triples>   <analystname>pawel dziedzic</analystname>   <documentformat>pdf</documentformat> </content> 

i have made relationship between these 2 embedded triples

prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>  insert data {    <http://company#cst_mining_group_limited> rdfs:subclassof <http://company#bodycote_plc> .  } 

when query results economicsector of bodycote plc, both of triples, correct, when use combined query not give me required results.

for example, when query has economic sector of bodycote , analyst name henrik christiansson, want return first triple not.

i used following query:

xquery version "1.0-ml";  import module namespace sem = "http://marklogic.com/semantics"    @ "/marklogic/semantics.xqy";  sem:sparql(   'select ?subject    {      ?subject <http://relationship#istrbceconomicsectorof> <http://company#bodycote_plc>    }',   (),   (),   cts:and-query( (     cts:element-value-query( xs:qname("analystname"), "henrik christiansson" )   ) ) ) 

i wanted know if there way through can apply inferencing in combined queries also.

the problem approach cts:query selects relevant documents, not managed triple specifies subclass. not using real inferencing here, externalizing inference rules literally adding triples. use rulesets instead, more flexible, , work better well. see semantics guide details.

once have ruleset file in place, need wrap query in sem:store, , apply ruleset sem:ruleset-store:

sem:sparql(   '     select ?subject     {       ?subject <http://relationship#istrbceconomicsectorof <http://company#bodycote_plc>     }   ',   (),   (),   sem:ruleset-store(     "myrules",     sem:store(       (),       cts:and-query((        cts:element-value-query( xs:qname("analystname"), "henrik christiansson" )       ))     )   ) ) 

hth!


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -