2017-10-04 103 views
0

如何才能獲取表示圖結構 - 類和屬性層次結構(即沒有個人,屬性值)的三元組?通過SPARQL查詢獲取RDF圖的結構

+0

對於類層次結構:'構造物,其中 {子的rdfs:??subClassOf燮}'使用謂詞'RDFS類似財產層次:subPropertyOf' – AKSW

+0

或者做一個查詢: 'CONSTRUCT { ?s?p?o。 } WHERE {?值p {RDFS:subClassOf的rdfs:subPropertyOf} 性s PØ }' – AKSW

+0

謝謝,但似乎我也需要RDF:???型,貓頭鷹:等級:域:範圍的三倍。 – palandlom

回答

0

看來我需要rdf:type,owl:class等三胞胎。所以這是我的變種:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX owl:  <http://www.w3.org/2002/07/owl#> 

select ?s ?p ?o 
where 
{ 
    { 
     graph <http://graph.org/gr> 
     {  
      ?s rdf:type ?o. 
      ?s ?p ?o. 
     } 
     FILTER 
      (?o IN (owl:Class, owl:DatatypeProperty, owl:AnnotationProperty, owl:ObjectProperty, owl:DataRange, owl:Ontology, 
      owl:DataRange,owl:DeprecatedClass,owl:DeprecatedProperty,owl:OntologyProperty,rdfs:Class,owl:Restriction,owl:InverseFunctionalProperty, 
      owl:FunctionalProperty,owl:AllDisjointClasses,rdf:Property, rdfs:Datatype) 
      ) 
} 
UNION 
{ 
     graph <http://graph.org/gr> 
     { 
      ?s ?p ?o. 
     } 
     FILTER 
      (?p IN (rdfs:subClassOf,rdfs:subPropertyOf,rdfs:domain,rdfs:range,rdfs:label,rdfs:comment,rdfs:member, 
      rdf:first,rdf:rest,owl:allValuesFrom,owl:someValuesFrom,owl:AnnotationProperty,owl:equivalentClass, 
      owl:equivalentProperty,owl:hasValue,owl:OntologyProperty,owl:SymmetricProperty,owl:TransitiveProperty, 
      owl:versionInfo,owl:priorVersion,owl:oneOf,owl:maxCardinality,owl:minCardinality,owl:inverseOf, 
      owl:incompatibleWith,owl:intersectionOf,owl:imports,owl:backwardCompatibleWith,owl:AllDifferent, 
      owl:differentFrom,owl:disjointWith,owl:distinctMembers,owl:complementOf,owl:cardinality,owl:unionOf,owl:onProperty)) 
     } 
} 
+0

下次應在您的問題中澄清這一點。這聽起來更像是你正在查詢OWL本體的所有模式公理。你仍然缺少像'?p rdf:type owl:FunctionalProperty'等公理。 – AKSW

+0

此外,你問三元組,因此,我不明白你爲什麼使用'SELECT'查詢。 – AKSW

+0

對不起,我用解決方案混淆了三元組。 – palandlom