最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

semantic web - get URI part of instance in SWRL rules - Stack Overflow

programmeradmin4浏览0评论

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#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#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 ?

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 ?

Share Improve this question asked Jan 24 at 17:01 slevinslevin 3,88821 gold badges76 silver badges140 bronze badges 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? – UninformedUser Commented Jan 27 at 7:51
  • @UninformedUser good idea, i will try it and let you know – slevin Commented Jan 27 at 17:00
  • @UninformedUser check my comments under the answer of user16930239. Thanks – slevin Commented Jan 28 at 22:08
Add a comment  | 

1 Answer 1

Reset to default 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)
发布评论

评论列表(0)

  1. 暂无评论