문제

나는 많은 개인에 대한 온톨로지를 가지고 있으며 Jena 추론기를 사용하여 그들에 대한 정보를 얻습니다.내 목표는 해당 규칙 내부에 제공된 정보를 기반으로 새로운 개인을 만들고 속성을 할당하는 것입니다.개인의 이름을 지정할 필요는 없지만 유형이 필요하고 몇 가지 속성의 일부여야 합니다.지금은 익명의 개인을 만들 수 있습니다. 메일링 리스트 게시물), 하지만 하나의 유형이나 하나의 속성만 제공할 수 있습니다.

내 문제의 작은 예는 다음과 같습니다.내 규칙은 다음과 같습니다(온톨로지 및 추론된 결과는 하단에서 찾을 수 있습니다).

[테스트2:(?X rdf:유형 NS:Test1) ->
[(?Y rdf:유형 NS:Test2) <- makeSkolem(?Y, ?X)]]

이는 Test1 개인이 발견되면 새로운 빈 노드가 생성되고 Test2 유형이 해당 노드에 지정됨을 의미합니다.잘 작동하지만 이 새로운 개인에게 ?X(Test1 개인)에 대한 분류 및 포인터(속성)를 제공하고 싶습니다.

"역방향 규칙은 하나의 헤드 절만 허용"하기 때문에 다음과 같은 것은 작동하지 않습니다.하지만 해당 조항의 모든 조항은 완벽하게 작동합니다.

[테스트2:(?X rdf:유형 NS:Test1) ->
[(?Y rdf:유형 NS:Test2), (?Y 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>

이것은 첫 번째 규칙(ID가 있는 빈 노드)의 결과입니다. A0 그리고 A1 새로운 개인입니다):

<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>
도움이 되었습니까?

해결책

첫째, 귀하의 규칙은 귀하가 말한 것과 정확히 일치하지 않는다는 점에 유의하십시오.

[테스트2:(?X rdf:유형 NS:Test1) →
[(?Y rdf:유형 NS:Test2) ← makeSkolem(?Y, ?X)]]

이는 Test1 개인이 발견되면 새로운 빈 노드가 생성되고 Test2 유형이 해당 노드에 지정됨을 의미합니다.

NS:Test1의 인스턴스가 발견되면 규칙이 일치하고, NS:Test2 유형이 있는지 여부를 결정할 때 사용할 수 있는 새로운 역방향 연결 규칙을 추가합니다.?X의 스콜렘이라면 그 유형을 갖고 있는 것입니다.요청하지 않는 한 NS:Test2 유형은 아무것도 제공하지 않습니다.(물론 전체 모델을 작성하려면 이러한 트리플이 필요합니다.)

해당 유형의 동작이 허용 가능하다고 판단되면 여러 개의 역방향 연결 규칙을 추가하는 순방향 연결 규칙을 사용할 수 있습니다. 예:

[테스트2:
(?X rdf:유형 NS:Test1) →
[(?Y rdf:유형 NS:Test2) ← makeSkolem(?Y, ?X)],
[(?Y NS:hasClassification '테스트') ← makeSkolem(?Y, ?X)]
]

내 생각에는 그것이 필요한 것보다 조금 더 복잡하다고 생각합니다.Skolem 객체는 다른 값에 의해 고유하게 결정되는 단순한 객체이므로 makeSkolem을 규칙의 헤드뿐만 아니라 규칙의 전제조건에도 사용할 수 있습니다.이는 다음을 수행할 수 있음을 의미합니다.

[테스트2:(?X rdf:유형 NS:Test1), makeSkolem(?Y, ?X) →
(?Y rdf:유형 NS:Test2), (?Y rdf:유형 NS:hasClassification '테스트')]

makeSkolem이 임의 개수의 인수를 취한다는 점은 주목할 가치가 있습니다.실수로 여러 위치에서 동일한 스콜렘 개체를 얻지 않도록 일종의 표시기를 추가하는 것이 좋습니다.예를 들어, 다음과 같은 것이 있다면

[(?child rdf:type :Child), makeSkolem(?mother, ?child) →
(?mother rdf:type:어머니), (?child:has어머니 ?어머니)]

[(?child rdf:type :Child), makeSkolem(?father, ?child) →
(?아버지 rdf:유형:아버지), (?자식:has아버지 ?아버지)]

그러면 실제로는 하나 각 어린이에 대해 skolem 개체를 만들고 이를 어린이의 어머니와 아버지라고 부르는데, 이는 아마도 원하는 것이 아닐 것입니다.대신 다음과 같은 작업을 수행할 수 있습니다.

[(?child rdf:type :Child), makeSkolem(?mother, ?child, '어머니') →
(?mother rdf:type:어머니), (?child:has어머니 ?어머니)]

[(?child rdf:type :Child), makeSkolem(?father, ?child, 'father') →
(?아버지 rdf:유형:아버지), (?자식:has아버지 ?아버지)]

부터 (?child, 'mother') 그리고 (?child, 'father') 항상 다르기 때문에 하나가 아닌 두 개의 스콜렘 개체를 얻습니다.예를 들어, 규칙에서 이와 같은 것을 사용할 수 있습니다.

[테스트2:(?X rdf:유형 NS:Test1), makeSkolem(?Y, ?X, 'test2') →
(?Y rdf:유형 NS:Test2), (?Y NS:hasClassification '테스트')]

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top