Hi Geert,

 I am not sure about my syntax so, I tried point 6 given in marklogic
documentation at "
https://developer.marklogic.com/features/semantics/inference-examples";
regarding "Define your own ruleset".

I followed all the steps given in example but in the last step, where it
references custom rule; it doesn't return any result. I am using marklogic
8.0.3 on windows 7 machine.



Prateek Jain

Cell : +91-9958646136

--------------------------------------------------------------
EXPECTATION : Causes all troubles......
--------------------------------------------------------------

On Mon, Jul 6, 2015 at 12:02 AM, Geert Josten <[email protected]>
wrote:

>  Hi Prateek,
>
>  It would help if you provide more detail. If you run this query from
> Qconsole, against which database are you running it then (the dropdown at
> the top of QConsole)? And does this database contain triple data? You can
> discover that using the Explore button which should reveal XML triple
> files, or using count(cts:triples()) in a new Qconsole query against the
> same database.
>
>  Note that your ruleset needs to be stored in the schemas database that
> is connected to the documents database that you are using..
>
>  Cheers,
> Geert
>
>   From: "[email protected]" <[email protected]>
> Reply-To: MarkLogic Developer Discussion <[email protected]>
> Date: Sunday, July 5, 2015 at 8:20 PM
>
> To: MarkLogic Developer Discussion <[email protected]>
> Subject: Re: [MarkLogic Dev General] How to include inference rules
>
>
> Hi Geert,
>
>   I am running this script now. It runs w/o error but doesnt return ant
> results. I am not sure if, I am missing something here. Also, I am not sure
> how to pass my data in query like, I want to get all banks in uk.
>
>
>  let $my-store := sem:ruleset-store("/rules/bankAt.rules", sem:store() )
> return
>  (: use the store you just created - pass it in to sem:sparql() :)
>  sem:sparql('
> PREFIX ex: <http://example.com/>
> PREFIX gn: <http://www.geonames.org/ontology/>
>
>  SELECT ?bank ?placeName
> FROM <http://marklogic.com/semantics/sb/banks/inf-1>
> WHERE
>  {
>  ?bank ex:bankAt ?place .
>  ?place gn:name ?placeName
>  }
>  ORDER BY ?bank
> ', (), (),
>  $my-store
>  )
>
>  Prateek Jain
>
> Cell : +91-9958646136
>
> --------------------------------------------------------------
> EXPECTATION : Causes all troubles......
> --------------------------------------------------------------
>
> On Sun, Jul 5, 2015 at 11:37 PM, Geert Josten <[email protected]>
> wrote:
>
>>  Hi Prateek,
>>
>>  Which error do you get?
>>
>>  Cheers,
>> Geert
>>
>>   From: "[email protected]" <[email protected]>
>> Reply-To: MarkLogic Developer Discussion <[email protected]
>> >
>> Date: Sunday, July 5, 2015 at 8:05 PM
>> To: MarkLogic Developer Discussion <[email protected]>
>> Subject: Re: [MarkLogic Dev General] How to include inference rules
>>
>>
>> Thanks Geert,
>>
>>   I have already created rule for inferencing by:
>>
>>  xquery version "1.0-ml";
>> xdmp:document-insert(
>> '/rules/bankAt.rules',
>> text{
>> '
>> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns>
>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema/>
>> PREFIX ex: <http://example.com/>
>> PREFIX gn: <http://www.geonames.org/ontology/>
>>
>>  rule "bankAt" CONSTRUCT {
>>   ?bank ex:bankAt ?place2
>> } {
>>   ?bank ex:bankAt ?place1 .
>>   ?place1 gn:parentFeature ?place2
>> }
>> '
>> }
>> )
>>
>>  And this is running w/o error. My issue is I am trying to use it in my
>> query like
>>
>>
>>  let $my-store := sem:ruleset-store("/rules/bankAt.rules", sem:store() )
>> return
>>  (: use the store you just created - pass it in to sem:sparql() :)
>>  sem:sparql('
>> PREFIX ex: <http://example.com/>
>>
>>  SELECT ?bank ?placeName
>> FROM <http://marklogic.com/semantics/sb/banks/inf-1>
>> WHERE
>>  {
>>  ?bank ex:bankAt ?place .
>>  ?place gn:name ?placeName
>>  }
>>  ORDER BY ?bank
>> ', (), (),
>>  $my-store
>>  )
>>
>>
>>  This is giving me error. I am confused on how to use custom rule
>> (syntatically)
>>
>>  Prateek Jain
>>
>> Cell : +91-9958646136
>>
>> --------------------------------------------------------------
>> EXPECTATION : Causes all troubles......
>> --------------------------------------------------------------
>>
>> On Sun, Jul 5, 2015 at 11:24 PM, Geert Josten <[email protected]
>> > wrote:
>>
>>>  Hi Prateek,
>>>
>>>  I see two options:
>>>
>>>    1. Specify ruleset programmatically using a sem:ruleset-store (see
>>>    http://docs.marklogic.com/guide/semantics/inferencing#id_pgfId-920824
>>>    )
>>>    2. Use default rulesets, which is a config setting for databases
>>>    (see
>>>    http://docs.marklogic.com/guide/semantics/inferencing#id_pgfId-919120
>>>    )
>>>
>>> Cheers,
>>> Geert
>>>
>>>   From: "[email protected]" <[email protected]>
>>> Reply-To: MarkLogic Developer Discussion <
>>> [email protected]>
>>> Date: Sunday, July 5, 2015 at 7:06 PM
>>> To: "[email protected]" <[email protected]>
>>> Subject: [MarkLogic Dev General] How to include inference rules
>>>
>>>   Hi,
>>>
>>>   I am facing issue while using custom inference rules in marklogic
>>> 8.0. Here is the scenario:
>>>
>>>  1. create data
>>>
>>>  PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>> PREFIX place: <http://example.com/places/>
>>> PREFIX ex: <http://example.com/>
>>> PREFIX bank: <http://example.com/banks/>
>>>
>>>  INSERT DATA
>>> {
>>>   GRAPH <http://marklogic.com/semantics/sb/banks/inf-1>
>>>   {
>>>     bank:1001 rdf:type ex:bank ;
>>>               ex:name "rbs" ;
>>>  ex:service "loan" , "asset management" , "fx" ;
>>>  place:name "london" .
>>>     bank:1002 rdf:type ex:bank ;
>>>               ex:name "rbi" ;
>>>  ex:service "loan" , "retail banking" , "guide lines" ;
>>>  place:name "delhi" .
>>>   }
>>> }
>>>
>>>  #------------- Define some places and their relationships-------------
>>>
>>>  DROP SILENT GRAPH <http://marklogic.com/semantics/sb/places/inf-1> ;
>>>
>>>  CREATE GRAPH <http://marklogic.com/semantics/sb/places/inf-1> ;
>>>
>>>
>>>  PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>> PREFIX place: <http://example.com/places/>
>>> PREFIX ex: <http://example.com/>
>>>
>>>  INSERT DATA
>>> {
>>>   GRAPH <http://marklogic.com/semantics/sb/places/inf-1>
>>>   {
>>>     place:1001 rdf:type ex:country ;
>>>               ex:name "uk" ;
>>>  ex:isin "Europe" .
>>>
>>> place:1002 rdf:type ex:city ;
>>>               ex:name "london" ;
>>>  ex:isin "uk" .
>>>
>>>   }
>>> }
>>>
>>>  2. Query w/o inference
>>>
>>>  PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>> PREFIX ex: <http://example.com/>
>>> PREFIX bank: <http://example.com/banks/>
>>> PREFIX place: <http://example.com/places/>
>>>
>>>  SELECT ?b
>>> FROM <http://marklogic.com/semantics/sb/banks/inf-1>
>>> WHERE
>>>   {
>>>     ?b rdf:type ex:bank ;
>>> place:name "london"
>>>   }
>>>
>>>  3. I know how to use inference via creating ontology data:
>>>
>>>  PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>>> PREFIX ex: <http://example.com/>
>>>
>>>  INSERT DATA
>>> {
>>>   GRAPH <http://marklogic.com/semantics/sb/banks/inf-1>
>>>   {
>>>     ex:city rdfs:subClassOf ex:country .
>>>   }
>>> }
>>>
>>>
>>>  -------------------------
>>> 4. Now, what I am trying to do is; achieve this via creating custom
>>> rules file. I have created "bankAt.rules" file under schemas database. Here
>>> is the code:
>>>
>>>  PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns>
>>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema/>
>>> PREFIX ex: <http://example.com/>
>>> PREFIX gn: <http://www.geonames.org/ontology/>
>>>
>>>  rule "bankAt" CONSTRUCT {
>>>   ?bank ex:bankAt ?place2
>>> } {
>>>   ?bank ex:bankAt ?place1 .
>>>   ?place1 gn:parentFeature ?place2
>>> }
>>>
>>>  I dont know how to use this rules file in my sparql query. I would be
>>> really helpful if someone can just list down the steps on "how to use this
>>> rule in sparql query".
>>>
>>>  Regards,
>>>
>>>  Prateek Jain
>>>
>>> --------------------------------------------------------------
>>> EXPECTATION : Causes all troubles......
>>> --------------------------------------------------------------
>>>
>>> _______________________________________________
>>> General mailing list
>>> [email protected]
>>> Manage your subscription at:
>>> http://developer.marklogic.com/mailman/listinfo/general
>>>
>>>
>>
>> _______________________________________________
>> General mailing list
>> [email protected]
>> Manage your subscription at:
>> http://developer.marklogic.com/mailman/listinfo/general
>>
>>
>
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
>
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to