[英]Sparql Query to retrieve all the properties and classes belong to specific class
I have ontology URI and I need to know all the properties and classes belongs to this ontology.我有本体 URI,我需要知道属于这个本体的所有属性和类。 the URI of the ontology Prefix Names: http://data.Ordanancesurvery.cor.uk/ontology/OpenName# .
本体前缀名称的 URI: http://data.Ordanancesurvery.cor.uk/ontology/OpenName# 。 It is hosted by ordnance survey and The API is: https://data.ordnancesurvey.co.uk/datasets/os-linked-data/explorer/sparql I need Sparql query which can retrieve all the classes and properties from the ontology.
它由军械测量局主办,API 是: https://data.ordnancesurvey.co.uk/datasets/os-linked-data/explorer/sparql我需要 Sparql 查询,它可以从本体中检索所有类和属性。
PREFIX Names: <http://data.ordnancesurvey.co.uk/ontology/OpenNames/>
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl:<http://www.w3.org/2002/07/owl#>
SELECT ?s ?p ?o
WHERE {
?s ?p ?o
Filter (regex (?o,"OpenNames"))
}
I am trying to retrieve all the classes and properties, belong to the ontology OpenNames under the uri: http://data.ordnancesurvey.co.uk/ontology/OpenNames/我正在尝试检索所有类和属性,属于 uri 下的本体 OpenNames: http://data.ordnancesurvey.co.uk/ontology/OpenNames/
URIs are not strings. URI 不是字符串。 Conversion is not automatic.
转换不是自动的。 Use
str(?o)
使用
str(?o)
regex (str(?o),"OpenNames")
or CONTAINS(str(?o),"OpenNames")
regex (str(?o),"OpenNames")
或CONTAINS(str(?o),"OpenNames")
Better is更好的是
STRSTARTS(str(?o), str(Names:))
Prefixes are expanded during parsing so前缀在解析过程中被扩展,所以
str(Names:)
is the same as writing和写一样
str(<http://data.ordnancesurvey.co.uk/ontology/OpenNames/>)
then STRSTARTS
does a leading string test.然后
STRSTARTS
进行前导字符串测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.