axiothOntology Hub

オントロジーとは何かを学ぶ / 第 3 部 設計と品質 · レッスン 13 / 16

選択した言語の翻訳がないため、Englishの内容を表示しています。

SHACL: checking that data has the right shape

Write required properties, counts and value types as shapes, and get violations reported.

An ontology says what is true. It does not check that the data arrived complete. A requirement such as "a person must have exactly one name" is written in SHACL, and the written requirement is called a shape.

Break the data on purpose

Shape: a person has exactly one name, and whatever they keep must be an animal.

Data

ex:minji a ex:Person .
ex:minji ex:name "Minji" .
ex:minji ex:keeps ex:nabi .
ex:nabi a ex:Cat .   # Cat ⊂ Animal
ex:seoul a ex:City .

Validation report

sh:conforms true · conforms to the shape

    Use the buttons above to cause a violation.

    Writing a shape

    A shape says two things: what to check (the target) and what must hold (the constraints).

    ex:PersonShape a sh:NodeShape ;
      sh:targetClass ex:Person ;                 # who is checked
      sh:property [
        sh:path ex:name ;                        # which property
        sh:minCount 1 ; sh:maxCount 1 ;          # exactly one
        sh:datatype xsd:string
      ] ;
      sh:property [
        sh:path ex:keeps ;
        sh:class ex:Animal                       # the value must be an animal
      ] .
    ConstraintMeaning
    sh:minCount, sh:maxCountHow many values
    sh:datatypeThe kind of value: string, integer, date
    sh:classThe class the value must belong to
    sh:pattern, sh:minLengthThe form of a string
    sh:inA list of allowed values
    sh:closedNo properties other than those listed

    The result is a report

    The outcome is RDF too. It says whether everything passed (sh:conforms) and, per violation, which node (sh:focusNode), which property (sh:resultPath) and which constraint.

    Think the opposite way to OWL

    OWL treats what is not stated as unknown. SHACL judges only what is in the graph now. If a name is missing, OWL assumes it exists somewhere; SHACL reports a violation. So they are used together: the ontology fixes meaning, shapes protect quality.

    When choosing an ontology, see whether shapes are published with it. They are the most concrete guide to how data for that ontology should be filled in. The application profiles of DCAT are published this way.

    実際のオントロジーで確認する

    仕様でさらに読む