slevin
slevin

Reputation: 3878

get URI part of instance in SWRL rules

I have some instances created by makeOWLThing , they have some random string, like abc123. They appear in protege as abc123 and in their details, their URI is example.com#abc123

How can I extract the abc123 part of the URI, in SWRL? I want to use it as a string in swrlb:stringConcat . Something like

ns0:modification(?o, ?m) ^ 
swrlx:makeOWLThing(?s, ?m) ^ # new ?s has URI example.com#abc123
rdfs:uriName(?, ?name) ^ # get the abc123 part
swrlb:stringConcat(?newname, "hello_", ?name) # concat hello_abc123
-> 
ss:general(?s) ^ 
ss:generalLabel(?s, ?newname) # pass hello_abc123 as label

So, ?name is a string abc123 and ?newname should be hello_abc123 , that is going to be the label of general's label.

rdfs:uriName(?, ?name) is not a real property, its an example to help you understand what I want and what is my logic

How can I do that ?

Upvotes: 1

Views: 16

Answers (1)

user16930239
user16930239

Reputation: 9706

Try this:

ns0:modification(?o, ?m) ^ 
swrlx:makeOWLThing(?s, ?m) ^  
swrlb:substringAfter(?s, "http://example.com#", ?name) ^  
swrlb:stringConcat("hello_", ?name, ?newname) ^  
-> 
ss:general(?s) ^ 
ss:generalLabel(?s, ?newname)

Upvotes: 0

Related Questions