回复: Store conditional data in plain RDF

Dear Ryan:
       Let's use that body mass index as an example:
 :Person :hasWeight :Weight;
                  :hasHeight :Height;
                  :hasBMI :BMI.        #BMI= Weight/(Height^2)
    if BMI<18.5 then {:Person :bodyType :Underweight}
    else if BMI >=18.5 and BMI <=24.9 then  {:Person :bodyType :NormalWeight}
    else {:Person :bodyType :OverWeight}

My idea is to store conditional data like this:

:rule1  :order  1 ;
           :hasSubject  :Person ;
           :hasPredicate :bodyType;
           :hasObject :Underweight;
           :condition [:cSubject :BMI;
                             :inRange [:upperLimit 18.4];
                             ] .

:rule2  :order  2 ;
           :hasSubject  :Person ;
           :hasPredicate :bodyType;
           :hasObject :NormalWeight;
           :condition [:cSubject :BMI;
                             :inRange [:lowerLimit 18.5 ;
                                             :upperLimit 24.9 ]
                                             ] .

:rule3  :order  3 ;
           :hasSubject  :Person ;
           :hasPredicate :bodyType;
           :hasObject :OverWeight;
           :condition [:cSubject :BMI;
                             :inRange [:lowerLimit 25];
                             ] .
Because I only need to store and display rule data and not reason in real time,  so I can read the data again when needed and reconstruct an N3 file for reasoning.
Assume that the above rules apply only to Asians, and that Americans need a different version of the rules.  So I can't store the rule data as a string, because I need to query and compare the boundary values of rules from different versions.

Best,
Joylix
________________________________
发件人: Shaw, Ryan <ryanshaw@unc.edu>
发送时间: 2021年10月27日 7:26
收件人: Joy lix <joylix4112@outlook.com>; public-n3-dev@w3.org <public-n3-dev@w3.org>
主题: Re: Store conditional data in plain RDF


> On Oct 25, 2021, at 11:01 AM, Joy lix <joylix4112@outlook.com> wrote:
>
> I wanted to store these data in rdf turtle or in graph database,  and read it with SPARQL or RDFLib when needed,  then reConstruct (using python or java)  a new N3 file or SHACL file  to do the reasoning.

Unless you actually need to query over the constituent parts of the rules, why not store the N3 rules as string literals? You can still connect them to the data to which they apply and get them back with SPARQL queries.

Ryan

Received on Wednesday, 27 October 2021 02:33:24 UTC