How to get all associated nodes of a blank node

48 views
Skip to first unread message

lix joy

unread,
Apr 24, 2022, 10:40:21 AM4/24/22
to rdflib-dev
Hi, all,  I'm new to RDflib,  I want to implement a feature like this:
To say, Person hasProperty Weight(kg) , Height(m), and BMI (Body Mass Index)=Weight/Height^2,  so if Bob‘s Weight=70, Height=1.75, How to deduce Bob's BMI from this model?
I use the following RDF file to store the above information:

@prefix : <http://ex.org/BMI#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
:Person rdf:type owl:Class;
         :hasProperty :Height, :Weight, :BMI.
:OriginalProperty rdf:type owl:Class .
:DerivedProperty rdf:type owl:Class .
:Weight rdf:type owl:Class ;
        rdfs:subClassOf :OriginalProperty .
:Height rdf:type owl:Class ;
        rdfs:subClassOf :OriginalProperty .
:BMI rdf:type owl:Class ;
     rdfs:subClassOf :DerivedProperty ;
     :equalTo [:divide (:Weight [:power  :Height])] .
:MathOperator rdf:type owl:Class .
:equalTo rdf:type owl:Class ;
         rdfs:subClassOf :MathOperator .
:divide rdf:type owl:Class ;
           rdfs:subClassOf :MathOperator .
:power rdf:type owl:Class ;
       rdfs:subClassOf :MathOperator .
:Bob rdf:type owl:NamedIndividual , :Person ;
     :hasProperty :BMIOfBob ,
                  :HeightOfBob ,
                  :WeightOfBob .
:HeightOfBob rdf:type owl:NamedIndividual , :Height ;
            :hasValue 1.75 .
:WeightOfBob rdf:type owl:NamedIndividual , :Weight ;
            :hasValue 70 .
:BMIOfBob rdf:type owl:NamedIndividual ,:BMI.

My idea is to read all the formulas for DerivedProperty through RDFLIB,  
Bob's BMI was then calculated in python. Now my question is how do I read all the associated information of this blank node in "equalTo" by rdflib? 
Or is there a better way to implement the functionality of this model with RDF?  

Thank you for any help and advice.

Joylix


Nicholas Car

unread,
Apr 24, 2022, 9:24:56 PM4/24/22
to rdfli...@googlegroups.com
Dear Joylix,

It’s great that you’re using RDFLib but this email list is for technical matters relating to the RDFLib software, not usage questions. 

Please post this question on StackOverflow where you can tag it with [rdflib].

Thanks, Nick
--
http://github.com/RDFLib
---
You received this message because you are subscribed to the Google Groups "rdflib-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rdflib-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rdflib-dev/006d3417-54e7-4ced-9b3a-b5f360ab837dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages