swrlx:makeOWLThing is creating only one individual

风格不统一 提交于 2019-12-11 05:08:49

问题


Using Protege and SWRL tab, I have the ontology mentioned hereinafter. It is composed of the Class Test and the class Shadow, where Test has three individuals t1, t2, t3. I was trying to define an SWRL rule that creates an individual of Shadow class for each existing individual of Test, the rule is

Test(?x) ^ swrlx:makeOWLThing(?new, ?x) -> Shadow(?new)

QUESTIONS:

  1. Only one individual of Shadow, named fred is created, instead of three (corresponding to t1, t2, t3).
  2. How to control the naming of the resulting individual which is always named fred?

    Prefix(:=<http://www.semanticweb.org/hilal/ontologies/2016/5/untitled-    ontology-58#>)
    Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
    Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
    Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
    Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
    Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)                
    Ontology(<http://www.semanticweb.org/hilal/ontologies/2016/5/untitled- ontology-58>
    
    Declaration(Class(:Shadow))
    Declaration(Class(:Test))
    Declaration(NamedIndividual(:t1))
    Declaration(NamedIndividual(:t2))
    Declaration(NamedIndividual(:t3))
    Declaration(AnnotationProperty(<http://swrl.stanford.edu/ontologies/3.3/swrla.owl#isRuleEnabled>))
    
    
    
    ############################
    #   Named Individuals
    ############################
    
    # Individual: :t1 (:t1)
    
    ClassAssertion(:Test :t1)
    
    # Individual: :t2 (:t2)
    
    ClassAssertion(:Test :t2)
    
    # Individual: :t3 (:t3)
    
    ClassAssertion(:Test :t3)
    
    
    DLSafeRule(Annotation(<http://swrl.stanford.edu/ontologies/3.3/swrla.owl#isRuleEnabled> "true"^^xsd:boolean) Annotation(rdfs:comment ""^^xsd:string) Annotation(rdfs:label "S1"^^xsd:string) Body(BuiltInAtom(<http://swrl.stanford.edu/ontologies/built-ins/3.3/swrlx.owl#makeOWLThing> Variable(<new>) Variable(<x>)) ClassAtom(:Test Variable(<x>)))Head(ClassAtom(:Shadow Variable(<new>))))
    )
    

回答1:


SWRL rules cannot create new individuals, as far as I understand the DL Safe conditions.




回答2:


In the comments, you linked to an article describing the semantics of that extension:

One of the the first built-ins I implemented provided the ability to create new individuals in a controlled manner. There is a detailed explanation in [2], but basically a built-in called swrlx:makeOWLThing creates a new individual and binds it to its first unbound argument; a new individual is created for each unique pattern of the remaining arguments.

Now, let's take a look at your rule as written in the question:

Test(?x) ^ swrlx:makeOWLThing(?new, ?x) -> Shadow(?new)

If the atoms are processed from left to right, then ?x should be bound when makeOWLThing is encountered, but ?new isn't. That means that you should get a new individuals bound to the variable ?new, and for each value of ?x you should get a different value of ?new. That's what it sounds like you want. However, in the code you posted, I see this:

DLSafeRule(
  Annotation(<http://swrl.stanford.edu/ontologies/3.3/swrla.owl#isRuleEnabled> "true"^^xsd:boolean)
  Annotation(rdfs:comment ""^^xsd:string)
  Annotation(rdfs:label "S1"^^xsd:string)

  Body(
    BuiltInAtom(<http://swrl.stanford.edu/ontologies/built-ins/3.3/swrlx.owl#makeOWLThing>
      Variable(<new>)
      Variable(<x>))
    ClassAtom(:Test Variable(<x>)))

  Head(
    ClassAtom(:Shadow Variable(<new>))))
)

I'm not certain, but if that's processed from left to right as well, the makeOWLThing(?new,?x) appears first, in which case ?x would be unbound when the new individual is created, so you'd only get one new individual.



来源:https://stackoverflow.com/questions/38016897/swrlxmakeowlthing-is-creating-only-one-individual

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!