sstenchlak / schema-generator

https://kodi-schema-generator.netlify.app/
0 stars 0 forks source link

Update SPARQL filtering conditions for class properties #11

Open martinnec opened 3 years ago

martinnec commented 3 years ago

SPARQL queries shall return attributes/associations which inherit from attributes/associations associated with a class. However only when these inheriting attributes/associations do not have their own domain/range.

E.g. it is necessary to add the following condition to the SPARQL query which returns attributes of a class:

   ?ancestorAttribute rdfs:subClassOf [
     owl:allValuesFrom <https://slovník.gov.cz/veřejný-sektor/pojem/právnická-osoba> ;
     owl:onProperty z:je-vlastností
   ] .
   ?attribute rdfs:subClassOf+ ?ancestorAttribute .
   **FILTER NOT EXISTS {
     ?attribute rdfs:subClassOf [
       owl:allValuesFrom [] ;
       owl:onProperty z:je-vlastností
     ] .
   }**
jakubklimek commented 3 years ago

image částka by neměla mít maximální plat

martinnec commented 3 years ago

SPARQL for inwards relations : ?rangeDefinition -> ?domainDefinition:

DEFINE sql:signal-void-variables 0

PREFIX z: <https://slovník.gov.cz/základní/pojem/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>

SELECT DISTINCT ?inwardsRelation ?domainElement WHERE {
 ?inwardsRelation a z:typ-vztahu ;
 skos:prefLabel ?inwardsRelationLabel ;
 skos:inScheme ?inwardsRelationGlossary .

 {
   ?inwardsRelation rdfs:subClassOf ?rangeDefinition .
   ?rangeDefinition owl:allValuesFrom <https://slovník.gov.cz/generický/částky/pojem/částka> ;
     owl:onProperty z:má-vztažený-prvek-2 .
 } UNION {
   ?ancestorInwardsRelation rdfs:subClassOf [
     owl:allValuesFrom <https://slovník.gov.cz/generický/částky/pojem/částka> ;
     owl:onProperty z:má-vztažený-prvek-2
   ] .
   ?inwardsRelation rdfs:subClassOf+ ?ancestorInwardsRelation .
 }

 {
   ?inwardsRelation rdfs:subClassOf ?domainDefinition .
   ?domainDefinition owl:allValuesFrom ?domainElement ;
     owl:onProperty z:má-vztažený-prvek-1 .
 } UNION {
   ?inwardsRelation rdfs:subClassOf/rdfs:subClassOf ?domainDefinition .
   ?domainDefinition owl:allValuesFrom ?domainElement ;
     owl:onProperty z:má-vztažený-prvek-1 .
   FILTER NOT EXISTS {
     ?inwardsRelation rdfs:subClassOf/owl:onProperty z:má-vztažený-prvek-1 .
   }
 } UNION {
   ?inwardsRelation rdfs:subClassOf+/rdfs:subClassOf ?domainDefinition .
   ?domainDefinition owl:allValuesFrom ?domainElement ;
     owl:onProperty z:má-vztažený-prvek-1 .
   FILTER NOT EXISTS {
     ?inwardsRelation rdfs:subClassOf+ ?specificInwardsRelation .
     ?specificInwardsRelation rdfs:subClassOf+ ?domainDefinition ;
     rdfs:subClassOf ?domainDefinition1 .
     ?domainDefinition1 owl:onProperty z:má-vztažený-prvek-1 .
   }
 }

 OPTIONAL { ?inwardsRelation skos:definition ?inwardsRelationDefinition }

 ?domainElement skos:prefLabel ?domainLabel ;
   skos:inScheme ?domainGlossary .

 OPTIONAL { ?domainElement skos:definition ?domainDefinition }

 OPTIONAL {
   ?inwardsRelation rdfs:subClassOf ?parentRelation .
   ?parentRelation a z:typ-vztahu .
   FILTER (?parentRelation != <https://slovník.gov.cz/základní/pojem/vztah>)
 }
}
martinnec commented 3 years ago

A pak něco nefunguje u Provozovatele - nemůžu na něm nic přidat - zřejmě problém s modelováním dědičnosti ve tvaru W

image

sstenchlak commented 3 years ago

I have fixed a problem with "maximální plat" (see hidden comments) ✔️ and the problem which was addressed here in the first comment. I am just not entirely sure whether the FILTER NOT EXISTS section should be copied somewhere else also, @martinnec.

sstenchlak/model-driven-data@fd370db