Re: 转发: Store conditional data in plain RDF

Hi Joy,

 

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

I don't know if this idea of mine is feasible and easy to implement, But I do need to do this in practice to store conditional data in plain RDF.  

 

                Being able to represent N3 in plain RDF (or Turtle for that matter) was discussed early on in the CG lifecycle. One can easily imagine an ad-hoc representation in RDF, e.g., writing quoted graphs (aka cited formulas) from rule premises and conclusions using reification, using first-rest chains for collections, and fully expanding resource paths into sets of triples. (To represent “=>”, you can simply use the “log:implies” predicate.) However, the resulting RDF would not have the exact same semantics as the original N3, as discussed in the GitHub thread. Alternatively, one can imagine a “meaningless” translation into RDF – e.g., instead of using standard reification, using something like N3Triple – n3Subject, n3Predicate, n3Object – to avoid the “semantic baggage” of RDF reification (as little as there is to begin with). 

 

However, either option would result in *very* verbose RDF code, inflating your required storage space and likely leading to unusable visualizations – which may remove the advantages of using mature and tested RDF tools altogether ..

 

 

William

 

From: Joy lix <joylix4112@outlook.com>
Date: Monday, October 25, 2021 at 12:02 PM
To: "public-n3-dev@w3.org" <public-n3-dev@w3.org>
Subject: 转发: Store conditional data in plain RDF
Resent-From: <public-n3-dev@w3.org>
Resent-Date: Mon, 25 Oct 2021 15:01:57 +0000

 

 

 

发件人: Joy lix
发送时间: 2021年10月25日 22:58
收件人: Jos De Roo <josderoo@gmail.com>
主题: re: Store conditional data in plain RDF 

 

Dear Jos: 

Thank you for your reply and help to my N3 grammar problem. As you suggested,  I copied this email to the mailing list ,so that other experts can provide professional advice and help. 

 

          I've been trying to store logical data containing  in plain RDF,   Because RDF can be read and visualized by many tools,   please have a look at this example :

#---------data.ttl ---------

@prefix : <#> .

:Person :drink :someLiquid .

:someLiquid :hasRule :rule1, :rule2.

:rule1 :forGender :Male ;

       :beverage :liquor .

:rule2 :forGender :Female ;

       :beverage :softDrinks .     

:Susan  a :Person ;

       :hasGender :Female .

:John a :Person ;

       :hasGender :Male .

 

#---using sparql query ---------

    PREFIX : <#>

     SELECT ?person ?gender ?beverage

     WHERE {

        :Person :drink :someLiquid .

        :someLiquid :hasRule ?rule .

        ?rule :forGender ?forGender ;

              :beverage ?beverage .

        ?person a :Person;        

             :hasGender ?gender .

      FILTER ( ?gender = ?forGender )

    }

 

#---and I get results:

 

1    person,   gender,   beverage

2    :Susan,  :Female,  :softDrinks

3    :John,   :Male,    :liquor

 

 

Another typical application scenario is:

     :Person :hasWeight :Weight;

                  :hasHeight :Height;

                  :hasBMI :BMI.        

                  #Body Mass Index, 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}

 

 

I think the generic RDF file looks something like this:

  :rule1 a :rule;

       :if :condition1, :condition2, :condition3;

       :then :statement1, :statement2;

       :else  :statement3.

 

       :condition1 a :condition;

       :hasSubject :condition1_Subject;

       :hasPredicate :condition1_Predicate;

       :hasObject :condition1_Object.

 

       :statement1

           :hasSubject :statement1_Subject;

           :hasPredicate :statement1_Predicate;

            :hasObject :statement1_Object.

 

      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. 

I don't know if this idea of mine is feasible and easy to implement, But I do need to do this in practice to store conditional data in plain RDF.  

    Thanks again.

 

Best regards,

Joylix

 

Received on Monday, 25 October 2021 15:29:27 UTC