sparql - SPARQL查询手工本体.owl
问题描述
我正在尝试从我建模的本体中进行 SPARQL 查询,但是在确定应该使用哪些前缀时遇到了麻烦。例如,如何从该本体、Pub 类中返回所有个体(owl:NamedIndividuals)以及所有子类数据(标签、描述、CID 等)?
对于此类查询,我使用 Protégé 'SPARQL Query' 插件
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?s ?o ?p
WHERE { ?s rdf:type owl:NamedIndividual .
FILTER ( ?s = 'Philosophy' )
}
本体: https ://ipfs.io/ipfs/QmYdBz4hTwhStf5eR7fv6imoKny82Y9QbyqNoZAbjceXiu
编辑。分享这个问题的部分解决方案
SELECT ?subject ?description ?date ?tags
WHERE {
#?subject <http://127.0.0.1:8000/gott2.owl#has_CID> <http://127.0.0.1:8000/gott2.owl#QmWCpZXGECFmwyoySt86LkJduE275iMffsNu6dFZ8q23h4>.
OPTIONAL {?subject <http://127.0.0.1:8000/gott2.owl#has_CID> ?object.}
OPTIONAL {?subject <http://127.0.0.1:8000/gott2.owl#has_description> ?description.}
OPTIONAL {?subject <http://127.0.0.1:8000/gott2.owl#has_tags> ?tags.}
OPTIONAL {?subject <http://127.0.0.1:8000/gott2.owl#has_date> ?date.}
BIND (STR(?subject) AS ?s) .
BIND (STR(?tags) AS ?t) .
OPTIONAL { FILTER CONTAINS ( LCASE(?s) , ENCODE_FOR_URI("philosophy"))} .
OPTIONAL { FILTER CONTAINS ( LCASE(?t) , ENCODE_FOR_URI("philosophy"))} .
}
解决方案
推荐阅读
- assembly - CPU在执行某些指令时是否关心DPL和RPL?
- c# - 如何使用 FromQuery 传递复杂的 C# 对象
- c# - 将哈希字符串值转换为 SHA256
- kubernetes - 在 Job pod 中的容器退出并且 sidecar 容器仍在运行后,网络端点被禁用
- python - 如何计算python上按2个特征分组的回归的学生化残差?
- javascript - 使用 fetch API 发送 POST 请求时处理 csrf 安全性
- c# - 将项目添加到枚举的扩展方法
- javascript - 复杂对象的扩展语法
- java - 如何持久化枚举值而不是序数
- mongodb - 如何缩放 mongodb 官方 docker 镜像