回复: 转发: Store conditional data in plain RDF

Dear William:
      Thanks for your reply.  I can't hide my fondness for N3 and especially for N3 inference, But how can N3 data be visualized and stored in a graph database, even in a workaround way?   Why does her child RDF work and she doesn't?  Please forgive me for using this inappropriate analogy,  It's like an elegant, beautiful woman, you can only feel her in words,  You can only see her eyes behind the mysterious veil, but you can't see her beautiful face, let alone touch her. This is really a matter of regret and heartache.
       I believe that maybe experts will find a good way to solve this problem soon,this will undoubtedly allow N3 to be more widely promoted and applied.
       In addition, as for the combined application of N3 and SHACL, I had a need, but I didn't know how to get started. I don't know whether there are corresponding examples and cases.

    Kind regards,
Joylix


________________________________
发件人: William Van Woensel <william.vanwoensel@gmail.com>
发送时间: 2021年10月25日 23:28
收件人: Joy lix <joylix4112@outlook.com>; public-n3-dev@w3.org <public-n3-dev@w3.org>
主题: 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<https://github.com/w3c/N3/issues/2> 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 Tuesday, 26 October 2021 00:24:42 UTC