1

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 ?

asked Jan 24, 2025 at 17:01
3
  • 1
    if you know the namespace in advance, you can use one of string built-ins of SWRL, or not? like swrlb:substringAfter or swrlb:replace does not work? Commented Jan 27, 2025 at 7:51
  • @UninformedUser good idea, i will try it and let you know Commented Jan 27, 2025 at 17:00
  • @UninformedUser check my comments under the answer of user16930239. Thanks Commented Jan 28, 2025 at 22:08

1 Answer 1

0

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)
answered Jan 27, 2025 at 17:38
Sign up to request clarification or add additional context in comments.

1 Comment

nice try, but , first of all, the right syntax for swrlb:substringAfter must be (?newString, ?string, "character") . In my case, swrlb:substringAfter(?newName, ?s, "#") . But another issue is that ?s is not a string, so I get an error. I could first use something like getURI() to get it as a string, but it is native to Apache jenna , not protege. Any other ideas ? Thanks

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.