Restriction on subClassOf limitation? or documentation not clear?

19 views
Skip to first unread message

Charbel Kaed

unread,
Nov 20, 2019, 6:44:49 PM11/20/19
to rdflib-dev
Hello, 

I am trying to use rdf lib to create the following: (a protege screenshot in the attachment)

  <Class rdf:about="http://www.abc#Building">
        <rdfs:subClassOf rdf:resource="http://www.abc#PhysicalLocation"/>
        <rdfs:subClassOf>
            <Restriction>
                <onProperty rdf:resource="http://www.abc#hasFloor"/>
                <allValuesFrom rdf:resource="http://abc#Floor"/>
            </Restriction>
        </rdfs:subClassOf>
        <rdfs:comment>This is a type for BUILDING facilities object</rdfs:comment>
        <rdfs:label>Building</rdfs:label>
    </Class>
    


But the only way I am able to create something are restrictions on properties and not classes such as:
<owl:ObjectProperty rdf:about="http://www.abc#hasFloor">
<rdfs:domain rdf:resource="http://www.abc#Building"/>
  <rdfs:subPropertyOf rdf:resource="http://www.abc#hasPhysicalLocation"/>
  <rdfs:range>
<owl:Restriction rdf:nodeID="N73e2705103db4e57b37b969e7a1d4780">
<owl:onProperty rdf:resource="http://www.abc#hasFloor"/>
      <owl:allValuesFrom rdf:resource="http://www.abc#Floor"/>
    </owl:Restriction>
</rdfs:range>
</owl:ObjectProperty>

Using the following code:


restriction_floor = Restriction(
constants.NS.hasFloor,
allValuesFrom=constants.NS.Floor,
graph=graph)
Property(
has_floor,
graph=graph,
domain=constants.NS.Building,
range=restriction_floor)

I would like to be able to create the restriction at the subClassOf level, how is it possible to do this?

Thank you
Best

Charbel
Screenshot from 2019-11-20 18-38-21.png

Nicholas Car

unread,
Dec 18, 2019, 6:49:18 AM12/18/19
to rdfli...@googlegroups.com
Hi Charbel,

Why don’t you just build up the graph by adding the triples you want like this:

g = Graph()
g.add((S1, P1, O1))
g.add((S2, P2, O2))
...

That gives you fine-grained control as you can add anything that RDF supports directly.

Nick 

— 
Dr Nicholas Car
Data Systems Architect
SURROUND Australia
0477 560 177

On 21 Nov 2019, at 10:44 am, 'Charbel Kaed' via rdflib-dev <rdfli...@googlegroups.com> wrote:


--
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/b3c19cbc-10db-4910-8d55-e84cce9ceb57%40googlegroups.com.
<Screenshot from 2019-11-20 18-38-21.png>
Reply all
Reply to author
Forward
0 new messages