簡體   English   中英

使用 Jena 規則創建多個 skolems

[英]Create multiple skolems with Jena rules

無需多次復制規則即可創建多個 skolems 的簡單方法是什么?

[ AddingMother:
    makeSkolem(?mother, "a mother")
    ->
(?mother rdf:title "mother") (?mother rdf:type _:Mother)
]

[ AddingChild:
    (?mother rdf:type _:Mother) makeSkolem(?child, "a child")
    ->
    (?child rdf:title "child") (?child rdf:type _:Child) (?child rdf:hasMother ?mother) (?mother rdf:hasChild ?child)
]

輸出是:

OYJ0Aokli2TZDVAK4EQzVA==  --{title}->  mother
OYJ0Aokli2TZDVAK4EQzVA==  --{type}->  :Mother
OYJ0Aokli2TZDVAK4EQzVA==  --{hasChild}->  8xEXOwnWH/tgxFN+HBwNeg==
8xEXOwnWH/tgxFN+HBwNeg==  --{title}->  child
8xEXOwnWH/tgxFN+HBwNeg==  --{type}->  :Child
8xEXOwnWH/tgxFN+HBwNeg==  --{hasMother}->  OYJ0Aokli2TZDVAK4EQzVA==

我想要五個孩子。 這里可以計數嗎? 我有點迷失在這里。

您可以根據需要對 skolem 使用盡可能多的參數,這樣您也可以讓孩子依賴於母親。 例如,這將使您每個母親都擁有一個獨特的孩子:

[ AddingChild:
    (?mother rdf:type _:Mother) makeSkolem(?child, "a child", ?mother)
    ->
    (?child rdf:title "child") (?child rdf:type _:Child) (?child rdf:hasMother ?mother) (?mother rdf:hasChild ?child)
]

基於此,如果您可以集成某種計數,例如生成索引,那么您可以為每個母親的每個索引生成一個孩子:

[ AddingChild:
    (?mother :hasChildIndex ?index)
    (?mother rdf:type _:Mother)
    makeSkolem(?child, "a child", ?mother, ?index)
    ->
    (?child rdf:title "child")
    (?child rdf:type _:Child)
    (?child rdf:hasMother ?mother)
    (?mother rdf:hasChild ?child)
]

順便說一句,您不應在標准未定義的命名空間中使用屬性,例如:

    (?child rdf:title "child")
    (?child rdf:hasMother ?mother)
    (?mother rdf:hasChild ?child)

一些推理器和 RDF 處理器會抱怨。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM