您没有提到“其子项的错误计数”是什么。当我在schema.org OWL 文档上运行您的查询时,我得到以下结果:
-------------------------------------------------------
| uri | childrenCount |
=======================================================
| <http://schema.org/UserInteraction> | 9 |
-------------------------------------------------------
我认为这个计数是正确的。如果您期望不同的计数,请更新问题以说明您期望的计数以及原因。根据schema.org Full Hierarchy页面显示了这个层次结构,在这个层次结构下,唯一的孙子类Event
是 的子类UserInteraction
,其中有九个。
无论如何,您在此列表中没有看到更多结果的原因是查询现在只找到实际上有自己孩子的孩子,这大大限制了您的结果。如果您想选择自己没有孩子的孩子,您可以选择模式Event
内部的孙子。为了显示:optional
Event
prefix schema: <http://schema.org/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select * where {
?child rdfs:subClassOf schema:Event .
optional {
?grandchild rdfs:subClassOf ?child
}
}
产生:
$ arq --data schemaorg.owl --query query.sparql
--------------------------------------------------
| child | grandchild |
==================================================
| schema:FoodEvent | |
| schema:Festival | |
| schema:SportsEvent | |
| schema:SaleEvent | |
| schema:EducationEvent | |
| schema:ChildrensEvent | |
| schema:DanceEvent | |
| schema:BusinessEvent | |
| schema:TheaterEvent | |
| schema:SocialEvent | |
| schema:VisualArtsEvent | |
| schema:MusicEvent | |
| schema:ComedyEvent | |
| schema:LiteraryEvent | |
| schema:UserInteraction | schema:UserCheckins |
| schema:UserInteraction | schema:UserTweets |
| schema:UserInteraction | schema:UserLikes |
| schema:UserInteraction | schema:UserPlays |
| schema:UserInteraction | schema:UserDownloads |
| schema:UserInteraction | schema:UserPlusOnes |
| schema:UserInteraction | schema:UserComments |
| schema:UserInteraction | schema:UserBlocks |
| schema:UserInteraction | schema:UserPageVisits |
--------------------------------------------------
的大多数子类Event
没有任何子类;只做UserInteraction
。也就是说,现在我们看到了如何找到这些类,即使它们没有子类,计数也应该与原来的查询非常相似:
prefix schema: <http://schema.org/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?child (count(?grandchild) as ?nGrandchildren) where {
?child rdfs:subClassOf schema:Event .
optional {
?grandchild rdfs:subClassOf ?child
}
}
group by ?child
当然,结果显示大多数类的计数为零,而UserInteraction
.
$ arq --data schemaorg.owl --query query.sparql
-------------------------------------------
| child | nGrandchildren |
===========================================
| schema:ComedyEvent | 0 |
| schema:ChildrensEvent | 0 |
| schema:SportsEvent | 0 |
| schema:FoodEvent | 0 |
| schema:BusinessEvent | 0 |
| schema:Festival | 0 |
| schema:EducationEvent | 0 |
| schema:LiteraryEvent | 0 |
| schema:SaleEvent | 0 |
| schema:TheaterEvent | 0 |
| schema:SocialEvent | 0 |
| schema:UserInteraction | 9 |
| schema:MusicEvent | 0 |
| schema:DanceEvent | 0 |
| schema:VisualArtsEvent | 0 |
-------------------------------------------