How to add an axiom on an instance in Ontology using rdflib?

71 views
Skip to first unread message

Ehsan Majidi

unread,
Jul 21, 2015, 8:48:16 AM7/21/15
to rdfli...@googlegroups.com

I want to define a restriction on my instance as you can see in the figure for Node_005 in the description window: connectedTo only {Arc_005}.
I made the following line of code using restriction:

g = Graph()
input_RDF
= g.parse(rdf_address)
nodeClass
= URIRef(rno+"Node")
arcClass
= URIRef(rno+"Segment")
namedIndividual
= URIRef('http://www.w3.org/2002/07/owl#NamedIndividual')
rdftype
= URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")
rno
= Namespace('http://example.com/RNO_v5042#')

nodeIndividualName=rno.Node_004
arcIndividualName=rno.Arc_004

g.add((nodeIndividualName,rdftype, nodeClass))
g
.add((nodeIndividualName,rdftype,namedIndividual))
g.add((nodeIndividualName,rno.is_extent_of, arcIndividualName))
g.add((arcIndividualName,rno.end_at, nodeIndividualName))


arcList = BNode()

linkCollection = Collection(g, arcList,[arcIndividualName])


Restriction(rno.connectedTo,graph=g, AllValuesFrom=
linkCollection, identifier=nodeIndividualName) #----->this is the restriction


the error is then:

    rest1 =Restriction(rno.is_extent_of, graph=g, value=node_arcs[nodeID])
  File "C:\Python27\ArcGISx6410.2\Lib\site-packages\rdflib\extras\infixowl.py", line 1651, in __init__
    (self.identifier, restrictionType, self.restrictionRange))
  File "C:\Python27\ArcGISx6410.2\Lib\site-packages\rdflib\graph.py", line 394, in add
    "Object %s must be an rdflib term" % (o,)
AssertionError: Object None must be an rdflib term


Can Restriction in rdflib produce such a thing for me? if so, what should be its configuration? If not, how can I define such an axiom for the individuals?


please consider that the list of items for the conecctedTo can be more than one.

Reply all
Reply to author
Forward
0 new messages