2014-02-27 71 views
2

我有一个很多个人的本体论,并且使用耶拿推理者来获取关于他们的信息。我的目标是根据规则中给定的信息创建新的个人并为其分配属性。个人不必命名,但他们需要一个类型,并且必须是少数属性的一部分。目前我可以创建匿名个人(在mailing list post的帮助下),但我只能给他们一个类型或一个属性。在耶拿规则里创建个人

这是我的问题的一个小例子;我的原则是这样的(本体和推断的结果可以在底部找到):

[测试2:(X RDF:类型NS:?Test1的) - >
        [(Y的rdf:类型NS:?的Test2)< - makeSkolem(Y,X)]]

这意味着当一个测试1个体中发现,则一个新的空白节点被创建,然后键入Test2授予能够节点。它工作正常,但我想给这个新的个人分类和指针(属性)?X(Test1个人)。

类似下面的内容不起作用,因为“后向规则只允许一个头句子”。尽管如此,其中的每个子句都完美无缺。

[TEST2:(X的rdf:类型NS:测试1) - (ÿ的rdf:类型NS:的Test2)>
        [(?ÿNS:hasClassification '测试'), < - makeSkolem(?Y,X)]]

这是我的本体论:

<rdf:RDF 
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
    xmlns:owl="http://www.w3.org/2002/07/owl#" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#" 
    xmlns="file:/Test#" 
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" > 
    <rdf:Description rdf:about="file:/Test#hasClassification"> 
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/> 
    </rdf:Description> 
    <rdf:Description rdf:about="file:/Test#TestProp"> 
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/> 
    </rdf:Description> 
    <rdf:Description rdf:about="file:/Test#testInd"> 
    <rdf:type rdf:resource="file:/Test#Test1"/> 
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/> 
    </rdf:Description> 
    <rdf:Description rdf:about="file:/Test#testInd2"> 
    <rdf:type rdf:resource="file:/Test#Test1"/> 
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/> 
    </rdf:Description> 
    <rdf:Description rdf:about="file:/Test#Test1"> 
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/> 
    </rdf:Description> 
    <rdf:Description rdf:about="file:/Test#Test2"> 
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/> 
    </rdf:Description> 
    <rdf:Description rdf:about="file:/Test"> 
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Ontology"/> 
    </rdf:Description> 
</rdf:RDF> 

这是与结果第一条规则(使用标识A0A1空白节点是新人类):

<rdf:RDF 
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
    xmlns:owl="http://www.w3.org/2002/07/owl#" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#" 
    xmlns="file:/Test#" 
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" > 
    <rdf:Description rdf:about="file:/Test#hasClassification"> 
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/> 
    </rdf:Description> 
    <rdf:Description rdf:nodeID="A0"> 
    <rdf:type rdf:resource="file:/Test#Test2"/> 
    </rdf:Description> 
    <rdf:Description rdf:about="file:/Test#TestProp"> 
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/> 
    </rdf:Description> 
    <rdf:Description rdf:about="file:/Test#testInd"> 
    <rdf:type rdf:resource="file:/Test#Test1"/> 
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/> 
    </rdf:Description> 
    <rdf:Description rdf:about="file:/Test#testInd2"> 
    <rdf:type rdf:resource="file:/Test#Test1"/> 
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/> 
    </rdf:Description> 
    <rdf:Description rdf:about="file:/Test#Test1"> 
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/> 
    </rdf:Description> 
    <rdf:Description rdf:about="file:/Test#Test2"> 
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/> 
    </rdf:Description> 
    <rdf:Description rdf:nodeID="A1"> 
    <rdf:type rdf:resource="file:/Test#Test2"/> 
    </rdf:Description> 
    <rdf:Description rdf:about="file:/Test"> 
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Ontology"/> 
    </rdf:Description> 
</rdf:RDF> 
+0

我用了反向链接规则,因为之前的makeSkolum()和我一起工作makeInstance()仅在后向/混合规则中可用。尝试使用makeInstance()一整天后,我没有考虑使用makeSkolum()使用简单的前向规则。它工作得非常好,但非常非常好(也适用于你的第二个解释)。我仍然有很多要了解耶拿,我很感谢你第二次帮助我。希望我在不久的将来再也不需要帮助。你是否想回答这个问题,以便我可以将其标记为已解决并给予您应有的信用? – ImmaCute

+0

我很高兴这有帮助!我已经添加了它的本质作为答案。 –

回答

1

首先,请注意您的规则没有做什么,你已经说过它。

[test2:(?X rdf:type NS:Test1)&rightarrow;
        [(?Y rdf:type NS:Test2)&leftarrow; makeSkolem(?Y,?X)]]

这意味着,当找到Test1个体时,将创建一个新的空白节点,然后将该类型的Test2赋予该节点。 Test1的被发现,并补充说,能够确定的东西是否具有类型NS时,可以使用一个新的反向链接的规则:

的规则时,一个instanceof NS匹配的Test2:如果它是X的斯科伦,那么它有这种类型。除非你提出要求,否则它不会提供任何类型的NS:Test2。 (写出整个模型当然会要求这样的三元组。)

如果您发现该类型的行为可以接受,那么您可以简单地使用向前链接规则,该规则会添加多个向后链接规则,例如,:

[TEST2:
   (X的rdf:类型NS:测试1)&RIGHTARROW;
        [(?Y rdf:type NS:Test2)&leftarrow; makeSkolem(?Y,?X)],
        [(?Y NS:hasClassification'test')&leftarrow; makeSkolem(?Y,?X)]
]

我认为这是一个有点复杂得多,它需要的。 Skolem对象只是由其他值唯一确定的对象,因此您可以在规则的前提条件以及规则的头部中使用makeSkolem。这意味着你可以这样做:

[test2:(?X rdf:type NS:Test1),makeSkolem(?Y,?X)&rightarrow;
       (Y RDF:?类型NS:Test2的),(Y RDF:?类型NS:hasClassification '测试')]

值得一提的是,makeSkolem需要的参数任意数量。添加某种指标可能是值得的,这样你就不会无意中在多个地方获得同一个skolem对象。例如,如果你有类似

[(?child rdf:type:Child),makeSkolem(?mother,?child)&rightarrow;
       ,:]

[(母亲RDF:型妈妈?)(孩子hasMother妈妈?)(孩子RDF:类型:儿童)(?父亲,孩子),makeSkolem&RIGHTARROW;
       (父亲RDF:?类型:父亲),(孩子:??hasFather父亲)

那么你实际上只创建一个每个孩子斯科伦对象并调用它孩子的母亲和父亲,这可能不是你想要的。相反,你可以这样做:

[(?child rdf:type:Child),makeSkolem(?mother,?child,'mother')&rightarrow;
       (母亲RDF:?类型:母亲),(孩子:??hasMother母亲)

[(孩子RDF:?类型:孩子)?,makeSkolem(父亲,孩子,“父亲') &右箭头;
       (父亲RDF:?类型:父亲),(孩子:??hasFather父亲)

自(?child'mother')和(?child'father')总是不同的,你得到两个skolem对象而不是一个。你可以在你的规则中使用类似的东西来获得,例如,

[test2:(?X rdf:type NS:Test1),makeSkolem(?Y,?X,'test2')&rightarrow;
       (Y RDF:?类型NS:Test2的),(Y NS:hasClassification '测试')]