From 177b36c1f7da89f18d0847443e5e49fc7b94a03a Mon Sep 17 00:00:00 2001 From: "John P. McCrae" Date: Wed, 6 Mar 2024 11:39:37 +0000 Subject: [PATCH 1/3] Update Examples and RDF spec --- .../RDF/elements/EtymonLanguage.xml | 2 +- .../RDF/elements/EtymonUnit.xml | 2 +- .../RDF/elements/ExampleTranslation.xml | 2 +- .../RDF/elements/HeadwordExplanation.xml | 2 +- .../RDF/elements/HeadwordTranslation.xml | 2 +- .../RDF/elements/LexicographicResource.xml | 2 +- .../serializations/RDF/elements/Member.xml | 6 ++-- .../RDF/elements/MemberType.xml | 2 +- .../serializations/RDF/elements/Sense.xml | 2 +- .../RDF/elements/TranslationLanguage.xml | 2 +- .../RDF/ontology/dmlex-core.ttl | 18 ++++++------ .../RDF/ontology/dmlex-linking.ttl | 8 +++--- .../serializations/RDF/ontology/dmlex.ttl | 28 +++++++++---------- 13 files changed, 38 insertions(+), 40 deletions(-) diff --git a/dmlex-v1.0/specification/serializations/RDF/elements/EtymonLanguage.xml b/dmlex-v1.0/specification/serializations/RDF/elements/EtymonLanguage.xml index 769baa62..32e0fd50 100644 --- a/dmlex-v1.0/specification/serializations/RDF/elements/EtymonLanguage.xml +++ b/dmlex-v1.0/specification/serializations/RDF/elements/EtymonLanguage.xml @@ -14,7 +14,7 @@ Properties - dmlex:langCode REQUIRED (exactly 1) of type http://www.w3.org/2001/XMLSchema#language + dmlex:langCode REQUIRED (exactly 1) of type http://www.w3.org/2001/XMLSchema#language (subproperty of http://www.w3.org/ns/lemon/lime#language) dmlex:displayName OPTIONAL (at most 1) of type http://www.w3.org/2001/XMLSchema#string diff --git a/dmlex-v1.0/specification/serializations/RDF/elements/EtymonUnit.xml b/dmlex-v1.0/specification/serializations/RDF/elements/EtymonUnit.xml index 5261dbe7..018002d4 100644 --- a/dmlex-v1.0/specification/serializations/RDF/elements/EtymonUnit.xml +++ b/dmlex-v1.0/specification/serializations/RDF/elements/EtymonUnit.xml @@ -17,7 +17,7 @@ dmlex:listingOrder REQUIRED (exactly 1) of type http://www.w3.org/2001/XMLSchema#nonNegativeInteger - dmlex:language REQUIRED (exactly 1) of type http://www.w3.org/2001/XMLSchema#language (subproperty of http://www.w3.org/ns/lemon/lime#language) + dmlex:langCode OPTIONAL of type http://www.w3.org/2001/XMLSchema#language (subproperty of http://www.w3.org/ns/lemon/lime#language) dmlex:partOfSpeech OPTIONAL reference to PartOfSpeech diff --git a/dmlex-v1.0/specification/serializations/RDF/elements/ExampleTranslation.xml b/dmlex-v1.0/specification/serializations/RDF/elements/ExampleTranslation.xml index 424fc32e..1c32b4aa 100644 --- a/dmlex-v1.0/specification/serializations/RDF/elements/ExampleTranslation.xml +++ b/dmlex-v1.0/specification/serializations/RDF/elements/ExampleTranslation.xml @@ -17,7 +17,7 @@ dmlex:listingOrder OPTIONAL of type http://www.w3.org/2001/XMLSchema#nonNegativeInteger - dmlex:language OPTIONAL (at most 1) of type http://www.w3.org/2001/XMLSchema#language (subproperty of http://www.w3.org/ns/lemon/lime#language) + dmlex:langCode OPTIONAL of type http://www.w3.org/2001/XMLSchema#language (subproperty of http://www.w3.org/ns/lemon/lime#language) dmlex:label OPTIONAL reference to Label diff --git a/dmlex-v1.0/specification/serializations/RDF/elements/HeadwordExplanation.xml b/dmlex-v1.0/specification/serializations/RDF/elements/HeadwordExplanation.xml index 5c6bf90f..e7070ad2 100644 --- a/dmlex-v1.0/specification/serializations/RDF/elements/HeadwordExplanation.xml +++ b/dmlex-v1.0/specification/serializations/RDF/elements/HeadwordExplanation.xml @@ -14,7 +14,7 @@ Properties - dmlex:language OPTIONAL (at most 1) of type http://www.w3.org/2001/XMLSchema#language (subproperty of http://www.w3.org/ns/lemon/lime#language) + dmlex:langCode OPTIONAL of type http://www.w3.org/2001/XMLSchema#language (subproperty of http://www.w3.org/ns/lemon/lime#language) dmlex:text REQUIRED (exactly 1) of type http://www.w3.org/2000/01/rdf-schema#Literal diff --git a/dmlex-v1.0/specification/serializations/RDF/elements/HeadwordTranslation.xml b/dmlex-v1.0/specification/serializations/RDF/elements/HeadwordTranslation.xml index 9e7dd574..08c99b73 100644 --- a/dmlex-v1.0/specification/serializations/RDF/elements/HeadwordTranslation.xml +++ b/dmlex-v1.0/specification/serializations/RDF/elements/HeadwordTranslation.xml @@ -17,7 +17,7 @@ dmlex:listingOrder REQUIRED (exactly 1) of type http://www.w3.org/2001/XMLSchema#nonNegativeInteger - dmlex:language OPTIONAL (at most 1) of type http://www.w3.org/2001/XMLSchema#language (subproperty of http://www.w3.org/ns/lemon/lime#language) + dmlex:langCode OPTIONAL of type http://www.w3.org/2001/XMLSchema#language (subproperty of http://www.w3.org/ns/lemon/lime#language) dmlex:partOfSpeech OPTIONAL reference to PartOfSpeech diff --git a/dmlex-v1.0/specification/serializations/RDF/elements/LexicographicResource.xml b/dmlex-v1.0/specification/serializations/RDF/elements/LexicographicResource.xml index 5c1a2be0..d3df9792 100644 --- a/dmlex-v1.0/specification/serializations/RDF/elements/LexicographicResource.xml +++ b/dmlex-v1.0/specification/serializations/RDF/elements/LexicographicResource.xml @@ -62,7 +62,7 @@ dmlex:etymonLanguage OPTIONAL reference to EtymonLanguage - dmlex:language REQUIRED (exactly 1) of type http://www.w3.org/2001/XMLSchema#language (subproperty of http://www.w3.org/ns/lemon/lime#language) + dmlex:langCode REQUIRED (exactly 1) of type http://www.w3.org/2001/XMLSchema#language (subproperty of http://www.w3.org/ns/lemon/lime#language) diff --git a/dmlex-v1.0/specification/serializations/RDF/elements/Member.xml b/dmlex-v1.0/specification/serializations/RDF/elements/Member.xml index 00e61a6a..7d134586 100644 --- a/dmlex-v1.0/specification/serializations/RDF/elements/Member.xml +++ b/dmlex-v1.0/specification/serializations/RDF/elements/Member.xml @@ -17,12 +17,10 @@ dmlex:listingOrder REQUIRED (exactly 1) of type http://www.w3.org/2001/XMLSchema#nonNegativeInteger - dmlex:ref REQUIRED (exactly 1) of type - http://www.w3.org/2001/XMLSchema#string + dmlex:ref REQUIRED (exactly 1) of type http://www.w3.org/2001/XMLSchema#string - dmlex:obverseListingOrder OPTIONAL (at most 1) of type - http://www.w3.org/2001/XMLSchema#integer + dmlex:obverseListingOrder OPTIONAL (at most 1) of type http://www.w3.org/2001/XMLSchema#integer dmlex:role OPTIONAL (at most 1) of type http://www.w3.org/2001/XMLSchema#string diff --git a/dmlex-v1.0/specification/serializations/RDF/elements/MemberType.xml b/dmlex-v1.0/specification/serializations/RDF/elements/MemberType.xml index 4461c6bf..e6f704c5 100644 --- a/dmlex-v1.0/specification/serializations/RDF/elements/MemberType.xml +++ b/dmlex-v1.0/specification/serializations/RDF/elements/MemberType.xml @@ -17,7 +17,7 @@ dmlex:description OPTIONAL (at most 1) of type http://www.w3.org/2000/01/rdf-schema#Literal - dmlex:type OPTIONAL of type http://www.w3.org/2001/XMLSchema#string + dmlex:type REQUIRED (exactly 1) of type http://www.w3.org/2001/XMLSchema#string dmlex:role OPTIONAL (at most 1) of type http://www.w3.org/2001/XMLSchema#string diff --git a/dmlex-v1.0/specification/serializations/RDF/elements/Sense.xml b/dmlex-v1.0/specification/serializations/RDF/elements/Sense.xml index 05437384..42d8a351 100644 --- a/dmlex-v1.0/specification/serializations/RDF/elements/Sense.xml +++ b/dmlex-v1.0/specification/serializations/RDF/elements/Sense.xml @@ -26,7 +26,7 @@ dmlex:label OPTIONAL reference to Label - dmlex:indicator OPTIONAL (at most 1) reference to Indicator + dmlex:indicator OPTIONAL (at most 1) of type http://www.w3.org/2000/01/rdf-schema#Literal dmlex:definition OPTIONAL reference to Definition diff --git a/dmlex-v1.0/specification/serializations/RDF/elements/TranslationLanguage.xml b/dmlex-v1.0/specification/serializations/RDF/elements/TranslationLanguage.xml index a59c518c..98c1639a 100644 --- a/dmlex-v1.0/specification/serializations/RDF/elements/TranslationLanguage.xml +++ b/dmlex-v1.0/specification/serializations/RDF/elements/TranslationLanguage.xml @@ -17,7 +17,7 @@ dmlex:listingOrder REQUIRED (exactly 1) of type http://www.w3.org/2001/XMLSchema#nonNegativeInteger - dmlex:langCode REQUIRED (exactly 1) of type http://www.w3.org/2001/XMLSchema#language + dmlex:langCode REQUIRED (exactly 1) of type http://www.w3.org/2001/XMLSchema#language (subproperty of http://www.w3.org/ns/lemon/lime#language) diff --git a/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex-core.ttl b/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex-core.ttl index 37606741..2799ba4f 100644 --- a/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex-core.ttl +++ b/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex-core.ttl @@ -39,7 +39,7 @@ dmlex:LexicographicResource a owl:Class ; rdfs:label "Lexicographic resource"@en ; rdfs:subClassOf [ a owl:Restriction ; - owl:onProperty dmlex:language ; + owl:onProperty dmlex:langCode ; owl:cardinality 1 ] , [ a owl:Restriction ; owl:onProperty dmlex:title ; @@ -59,17 +59,17 @@ dmlex:uri a owl:DatatypeProperty ; rdfs:domain dmlex:LexicographicResource ; rdfs:range xsd:anyURI . -dmlex:language a owl:DatatypeProperty ; +dmlex:langCode a owl:DatatypeProperty ; rdfs:label "Language"@en ; - rdfs:domain dmlex:HasLanguage ; + rdfs:domain dmlex:HasLangCode ; rdfs:range xsd:language ; rdfs:subPropertyOf lime:language . -dmlex:LexicographicResource rdfs:subClassOf dmlex:HasLanguage . -dmlex:HeadwordTranslation rdfs:subClassOf dmlex:HasLanguage . -dmlex:HeadwordExplanation rdfs:subClassOf dmlex:HasLanguage . -dmlex:ExampleTranslation rdfs:subClassOf dmlex:HasLanguage . -dmlex:EtymonUnit rdfs:subClassOf dmlex:HasLanguage . +dmlex:LexicographicResource rdfs:subClassOf dmlex:HasLangCode . +dmlex:HeadwordTranslation rdfs:subClassOf dmlex:HasLangCode . +dmlex:HeadwordExplanation rdfs:subClassOf dmlex:HasLangCode . +dmlex:ExampleTranslation rdfs:subClassOf dmlex:HasLangCode . +dmlex:EtymonUnit rdfs:subClassOf dmlex:HasLangCode . dmlex:entry a owl:ObjectProperty ; rdfs:label "Entry"@en ; @@ -217,7 +217,7 @@ dmlex:Sense a owl:Class ; dmlex:indicator a owl:ObjectProperty ; rdfs:label "Indicator"@en ; rdfs:domain dmlex:Sense ; - rdfs:range dmlex:Indicator . + rdfs:range rdfs:Literal . dmlex:definition a owl:ObjectProperty ; rdfs:label "Definition"@en ; diff --git a/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex-linking.ttl b/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex-linking.ttl index 17d2ba70..f47660d3 100644 --- a/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex-linking.ttl +++ b/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex-linking.ttl @@ -57,7 +57,7 @@ dmlex:Member a owl:Class ; rdfs:label "Member"@en ; rdfs:subClassOf [ a owl:Restriction ; - owl:onProperty dmlex:memberID ; + owl:onProperty dmlex:ref ; owl:cardinality 1 ] , [ a owl:Restriction ; owl:onProperty dmlex:role ; @@ -67,10 +67,10 @@ dmlex:Member a owl:Class ; owl:cardinality 1 ] , [ a owl:Restriction ; owl:onProperty dmlex:obverseListingOrder ; - owl:cardinality 1 ] . + owl:maxCardinality 1 ] . -dmlex:memberID a owl:DatatypeProperty ; - rdfs:label "Member ID"@en ; +dmlex:ref a owl:DatatypeProperty ; + rdfs:label "Ref"@en ; rdfs:domain dmlex:Member ; rdfs:range xsd:string . diff --git a/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex.ttl b/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex.ttl index 9434b0dc..f801dd01 100644 --- a/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex.ttl +++ b/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex.ttl @@ -39,7 +39,7 @@ dmlex:LexicographicResource a owl:Class ; rdfs:label "Lexicographic resource"@en ; rdfs:subClassOf [ a owl:Restriction ; - owl:onProperty dmlex:language ; + owl:onProperty dmlex:langCode ; owl:cardinality 1 ] , [ a owl:Restriction ; owl:onProperty dmlex:title ; @@ -59,17 +59,17 @@ dmlex:uri a owl:DatatypeProperty ; rdfs:domain dmlex:LexicographicResource ; rdfs:range xsd:anyURI . -dmlex:language a owl:DatatypeProperty ; +dmlex:langCode a owl:DatatypeProperty ; rdfs:label "Language"@en ; - rdfs:domain dmlex:HasLanguage ; + rdfs:domain dmlex:HasLangCode ; rdfs:range xsd:language ; rdfs:subPropertyOf lime:language . -dmlex:LexicographicResource rdfs:subClassOf dmlex:HasLanguage . -dmlex:HeadwordTranslation rdfs:subClassOf dmlex:HasLanguage . -dmlex:HeadwordExplanation rdfs:subClassOf dmlex:HasLanguage . -dmlex:ExampleTranslation rdfs:subClassOf dmlex:HasLanguage . -dmlex:EtymonUnit rdfs:subClassOf dmlex:HasLanguage . +dmlex:LexicographicResource rdfs:subClassOf dmlex:HasLangCode . +dmlex:HeadwordTranslation rdfs:subClassOf dmlex:HasLangCode . +dmlex:HeadwordExplanation rdfs:subClassOf dmlex:HasLangCode . +dmlex:ExampleTranslation rdfs:subClassOf dmlex:HasLangCode . +dmlex:EtymonUnit rdfs:subClassOf dmlex:HasLangCode . dmlex:entry a owl:ObjectProperty ; rdfs:label "Entry"@en ; @@ -217,7 +217,7 @@ dmlex:Sense a owl:Class ; dmlex:indicator a owl:ObjectProperty ; rdfs:label "Indicator"@en ; rdfs:domain dmlex:Sense ; - rdfs:range dmlex:Indicator . + rdfs:range rdfs:Literal . dmlex:definition a owl:ObjectProperty ; rdfs:label "Definition"@en ; @@ -670,7 +670,7 @@ dmlex:Member a owl:Class ; rdfs:label "Member"@en ; rdfs:subClassOf [ a owl:Restriction ; - owl:onProperty dmlex:memberID ; + owl:onProperty dmlex:ref ; owl:cardinality 1 ] , [ a owl:Restriction ; owl:onProperty dmlex:role ; @@ -680,10 +680,10 @@ dmlex:Member a owl:Class ; owl:cardinality 1 ] , [ a owl:Restriction ; owl:onProperty dmlex:obverseListingOrder ; - owl:cardinality 1 ] . + owl:maxCardinality 1 ] . -dmlex:memberID a owl:DatatypeProperty ; - rdfs:label "Member ID"@en ; +dmlex:ref a owl:DatatypeProperty ; + rdfs:label "Ref"@en ; rdfs:domain dmlex:Member ; rdfs:range xsd:string . @@ -730,7 +730,7 @@ dmlex:MemberType a owl:Class ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty dmlex:role ; - owl:cardinality 1 ] , [ + owl:maxCardinality 1 ] , [ a owl:Restriction ; owl:onProperty dmlex:type ; owl:cardinality 1 ] , [ From 3fbf99d0b29e507afc651baabe0239dc3c71da04 Mon Sep 17 00:00:00 2001 From: "John P. McCrae" Date: Wed, 6 Mar 2024 11:50:30 +0000 Subject: [PATCH 2/3] Start the work on the SHACL validation --- .../serializations/RDF/gen_shacl_from_rdf.py | 87 +++ .../serializations/RDF/ontology/dmlex.shacl | 723 ++++++++++++++++++ .../serializations/RDF/verify_shacl.sh | 7 + 3 files changed, 817 insertions(+) create mode 100644 dmlex-v1.0/specification/serializations/RDF/gen_shacl_from_rdf.py create mode 100644 dmlex-v1.0/specification/serializations/RDF/ontology/dmlex.shacl create mode 100644 dmlex-v1.0/specification/serializations/RDF/verify_shacl.sh diff --git a/dmlex-v1.0/specification/serializations/RDF/gen_shacl_from_rdf.py b/dmlex-v1.0/specification/serializations/RDF/gen_shacl_from_rdf.py new file mode 100644 index 00000000..efe61127 --- /dev/null +++ b/dmlex-v1.0/specification/serializations/RDF/gen_shacl_from_rdf.py @@ -0,0 +1,87 @@ +import rdflib +from collections import defaultdict +from rdflib.namespace import RDF, RDFS, OWL, URIRef +from rdflib.collection import Collection + +DMLEX = "http://www.oasis-open.org/to-be-confirmed/dmlex#" +DMLEX_SHACL = "http://www.oasis-open.org/to-be-confirmed/dmlex-shacl#" + +def parse_rdf(): + g = rdflib.Graph() + g.parse("ontology/dmlex.ttl", format="turtle") + + props = defaultdict(list) + for s, p, o in g.triples((None, RDFS.domain, None)): + if isinstance(o, rdflib.term.URIRef): + if str(o).startswith(DMLEX + "Has"): + for domain_class in g.subjects(RDFS.subClassOf, o): + props[domain_class].append(s) + else: + props[o].append(s) + else: + for listname in g.objects(o, OWL.unionOf): + for item in Collection(g, listname): + props[item].append(s) + + ranges = defaultdict(list) + for s, p, o in g.triples((None, RDFS.range, None)): + if isinstance(o, rdflib.term.URIRef): + ranges[s].append(o) + + with open("ontology/dmlex.shacl", "w") as file: + file.write("# This file was generated from dmlex.ttl by " + + "gen_shacl_from_rdf.py\n") + file.write("@prefix sh: .\n") + file.write(f"@prefix dmlex: <{DMLEX}> .\n") + file.write(f"@prefix : <{DMLEX_SHACL}> .\n\n") + for class_uri in g.subjects(RDF.type, OWL.Class): + if (isinstance(class_uri, rdflib.term.URIRef) and + not str(class_uri).startswith(DMLEX + "Has")): + uri = str(class_uri) + name = uri.split("#")[-1] + + subclasses = [] + restrictions = defaultdict(lambda: defaultdict(lambda: [0,-1])) + for o in g.objects(class_uri, RDFS.subClassOf): + if (isinstance(o, rdflib.term.URIRef) and + not str(o).startswith(DMLEX + "Has")): + subclasses.append(str(o)) + elif isinstance(o, rdflib.term.BNode): + for o2 in g.objects(o, OWL.onProperty): + for o3 in g.objects(o, OWL.cardinality): + restrictions[class_uri][o2] = [o3, o3] + for o3 in g.objects(o, OWL.maxCardinality): + restrictions[class_uri][o2] = [0, o3] + for o3 in g.objects(o, OWL.minCardinality): + restrictions[class_uri][o2] = [o3, -1] + file.write(f""" +:{name}Shape ; + a sh:NodeShape ; + sh:targetClass dmlex:{name} ; + sh:closed false""") + for prop in props[class_uri]: + file.write(f""" ; + sh:property [ + sh:path dmlex:{prop.split("#")[-1]} """) + if prop in restrictions[class_uri]: + min_card, max_card = restrictions[class_uri][prop] + if min_card >= 0: + file.write(f""" ; + sh:minCount {min_card}""") + if max_card >= 0: + file.write(f""" ; + sh:maxCount {max_card}""") + for range in ranges[prop]: + if range.startswith(DMLEX): + file.write(f""" ; + sh:class dmlex:{range.split("#")[-1]} """) + file.write(" ]") + + file.write(" .\n\n") + + + + + +if __name__ == "__main__": + parse_rdf() diff --git a/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex.shacl b/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex.shacl new file mode 100644 index 00000000..10fdadb0 --- /dev/null +++ b/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex.shacl @@ -0,0 +1,723 @@ +# This file was generated from dmlex.ttl by gen_shacl_from_rdf.py +@prefix sh: . +@prefix dmlex: . +@prefix : . + + +:LexicographicResourceShape ; + a sh:NodeShape ; + sh:targetClass dmlex:LexicographicResource ; + sh:closed false ; + sh:property [ + sh:path dmlex:title ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:uri ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:entry ; + sh:class dmlex:Entry ] ; + sh:property [ + sh:path dmlex:translationLanguage ; + sh:class dmlex:TranslationLanguage ] ; + sh:property [ + sh:path dmlex:definitionTypeTag ; + sh:class dmlex:DefinitionTypeTag ] ; + sh:property [ + sh:path dmlex:inflectedFormTag ; + sh:class dmlex:InflectedFormTag ] ; + sh:property [ + sh:path dmlex:labelTypeTag ; + sh:class dmlex:LabelTypeTag ] ; + sh:property [ + sh:path dmlex:partOfSpeechTag ; + sh:class dmlex:PartOfSpeechTag ] ; + sh:property [ + sh:path dmlex:sourceIdentityTag ; + sh:class dmlex:SourceIdentityTag ] ; + sh:property [ + sh:path dmlex:transcriptionSchemeTag ; + sh:class dmlex:TranscriptionSchemeTag ] ; + sh:property [ + sh:path dmlex:relation ; + sh:class dmlex:Relation ] ; + sh:property [ + sh:path dmlex:relationType ; + sh:class dmlex:RelationType ] ; + sh:property [ + sh:path dmlex:etymonType ; + sh:class dmlex:EtymonType ] ; + sh:property [ + sh:path dmlex:etymonLanguage ; + sh:class dmlex:EtymonLanguage ] ; + sh:property [ + sh:path dmlex:language ; + sh:minCount 1 ; + sh:maxCount 1 ] . + + +:EntryShape ; + a sh:NodeShape ; + sh:targetClass dmlex:Entry ; + sh:closed false ; + sh:property [ + sh:path dmlex:headword ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:homographNumber ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:sense ; + sh:class dmlex:Sense ] ; + sh:property [ + sh:path dmlex:etymology ; + sh:class dmlex:Etymology ] ; + sh:property [ + sh:path dmlex:partOfSpeech ; + sh:class dmlex:PartOfSpeech ] ; + sh:property [ + sh:path dmlex:label ; + sh:class dmlex:Label ] ; + sh:property [ + sh:path dmlex:pronunciation ; + sh:class dmlex:Pronunciation ] ; + sh:property [ + sh:path dmlex:inflectedForm ; + sh:class dmlex:InflectedForm ] ; + sh:property [ + sh:path dmlex:placeholderMarker ; + sh:class dmlex:PlaceholderMarker ] . + + +:PartOfSpeechShape ; + a sh:NodeShape ; + sh:targetClass dmlex:PartOfSpeech ; + sh:closed false ; + sh:property [ + sh:path dmlex:listingOrder ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:tag ; + sh:minCount 1 ; + sh:maxCount 1 ] . + + +:InflectedFormShape ; + a sh:NodeShape ; + sh:targetClass dmlex:InflectedForm ; + sh:closed false ; + sh:property [ + sh:path dmlex:listingOrder ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:label ; + sh:class dmlex:Label ] ; + sh:property [ + sh:path dmlex:pronunciation ; + sh:class dmlex:Pronunciation ] ; + sh:property [ + sh:path dmlex:tag ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:text ; + sh:minCount 1 ; + sh:maxCount 1 ] . + + +:SenseShape ; + a sh:NodeShape ; + sh:targetClass dmlex:Sense ; + sh:closed false ; + sh:property [ + sh:path dmlex:listingOrder ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:label ; + sh:class dmlex:Label ] ; + sh:property [ + sh:path dmlex:indicator ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:class dmlex:Indicator ] ; + sh:property [ + sh:path dmlex:definition ; + sh:class dmlex:Definition ] ; + sh:property [ + sh:path dmlex:example ; + sh:class dmlex:Example ] ; + sh:property [ + sh:path dmlex:headwordExplanation ; + sh:class dmlex:HeadwordExplanation ] ; + sh:property [ + sh:path dmlex:headwordTranslation ; + sh:class dmlex:HeadwordTranslation ] . + + +:DefinitionShape ; + a sh:NodeShape ; + sh:targetClass dmlex:Definition ; + sh:closed false ; + sh:property [ + sh:path dmlex:listingOrder ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:text ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:definitionType ; + sh:minCount 0 ; + sh:maxCount 1 ; + sh:class dmlex:DefinitionType ] ; + sh:property [ + sh:path dmlex:headwordMarker ; + sh:class dmlex:HeadwordMarker ] ; + sh:property [ + sh:path dmlex:collocateMarker ; + sh:class dmlex:CollocateMarker ] . + + +:LabelShape ; + a sh:NodeShape ; + sh:targetClass dmlex:Label ; + sh:closed false ; + sh:property [ + sh:path dmlex:listingOrder ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:tag ; + sh:minCount 1 ; + sh:maxCount 1 ] . + + +:PronunciationShape ; + a sh:NodeShape ; + sh:targetClass dmlex:Pronunciation ; + sh:closed false ; + sh:property [ + sh:path dmlex:listingOrder ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:label ; + sh:class dmlex:Label ] ; + sh:property [ + sh:path dmlex:soundFile ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:transcription ; + sh:class dmlex:Transcription ] . + + +:TranscriptionShape ; + a sh:NodeShape ; + sh:targetClass dmlex:Transcription ; + sh:closed false ; + sh:property [ + sh:path dmlex:listingOrder ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:text ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:scheme ; + sh:minCount 0 ; + sh:maxCount 1 ] . + + +:ExampleShape ; + a sh:NodeShape ; + sh:targetClass dmlex:Example ; + sh:closed false ; + sh:property [ + sh:path dmlex:listingOrder ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:label ; + sh:class dmlex:Label ] ; + sh:property [ + sh:path dmlex:text ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:soundFile ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:sourceIdentity ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:sourceElaboration ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:exampleTranslation ; + sh:class dmlex:ExampleTranslation ] ; + sh:property [ + sh:path dmlex:headwordMarker ; + sh:class dmlex:HeadwordMarker ] ; + sh:property [ + sh:path dmlex:collocateMarker ; + sh:class dmlex:CollocateMarker ] . + + +:TranslationLanguageShape ; + a sh:NodeShape ; + sh:targetClass dmlex:TranslationLanguage ; + sh:closed false ; + sh:property [ + sh:path dmlex:listingOrder ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:langCode ; + sh:minCount 1 ; + sh:maxCount 1 ] . + + +:HeadwordTranslationShape ; + a sh:NodeShape ; + sh:targetClass dmlex:HeadwordTranslation ; + sh:closed false ; + sh:property [ + sh:path dmlex:listingOrder ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:language ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:partOfSpeech ; + sh:class dmlex:PartOfSpeech ] ; + sh:property [ + sh:path dmlex:label ; + sh:class dmlex:Label ] ; + sh:property [ + sh:path dmlex:pronunciation ; + sh:class dmlex:Pronunciation ] ; + sh:property [ + sh:path dmlex:inflectedForm ; + sh:class dmlex:InflectedForm ] ; + sh:property [ + sh:path dmlex:text ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:placeholderMarker ; + sh:class dmlex:PlaceholderMarker ] . + + +:HeadwordExplanationShape ; + a sh:NodeShape ; + sh:targetClass dmlex:HeadwordExplanation ; + sh:closed false ; + sh:property [ + sh:path dmlex:language ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:text ; + sh:minCount 1 ; + sh:maxCount 1 ] . + + +:ExampleTranslationShape ; + a sh:NodeShape ; + sh:targetClass dmlex:ExampleTranslation ; + sh:closed false ; + sh:property [ + sh:path dmlex:listingOrder ] ; + sh:property [ + sh:path dmlex:language ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:label ; + sh:class dmlex:Label ] ; + sh:property [ + sh:path dmlex:text ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:soundFile ] ; + sh:property [ + sh:path dmlex:headwordMarker ; + sh:class dmlex:HeadwordMarker ] ; + sh:property [ + sh:path dmlex:collocateMarker ; + sh:class dmlex:CollocateMarker ] . + + +:DefinitionTypeTagShape ; + a sh:NodeShape ; + sh:targetClass dmlex:DefinitionTypeTag ; + sh:closed false ; + sh:property [ + sh:path dmlex:tag ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:description ; + sh:minCount 0 ; + sh:maxCount 1 ] . + + +:InflectedFormTagShape ; + a sh:NodeShape ; + sh:targetClass dmlex:InflectedFormTag ; + sh:closed false ; + sh:property [ + sh:path dmlex:inflectedForm ; + sh:class dmlex:InflectedForm ] ; + sh:property [ + sh:path dmlex:tag ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:description ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:forPartOfSpeech ] . + + +:LabelTagShape ; + a sh:NodeShape ; + sh:targetClass dmlex:LabelTag ; + sh:closed false ; + sh:property [ + sh:path dmlex:inflectedForm ; + sh:class dmlex:InflectedForm ] ; + sh:property [ + sh:path dmlex:tag ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:description ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:forPartOfSpeech ] ; + sh:property [ + sh:path dmlex:forCollocates ; + sh:minCount 0 ; + sh:maxCount 1 ] . + + +:LabelTypeTagShape ; + a sh:NodeShape ; + sh:targetClass dmlex:LabelTypeTag ; + sh:closed false ; + sh:property [ + sh:path dmlex:tag ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:description ; + sh:minCount 1 ; + sh:maxCount 1 ] . + + +:PartOfSpeechTagShape ; + a sh:NodeShape ; + sh:targetClass dmlex:PartOfSpeechTag ; + sh:closed false ; + sh:property [ + sh:path dmlex:inflectedForm ; + sh:class dmlex:InflectedForm ] ; + sh:property [ + sh:path dmlex:tag ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:description ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:forEtymology ; + sh:minCount 0 ; + sh:maxCount 1 ] . + + +:SourceIdentityTagShape ; + a sh:NodeShape ; + sh:targetClass dmlex:SourceIdentityTag ; + sh:closed false ; + sh:property [ + sh:path dmlex:tag ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:description ; + sh:minCount 0 ; + sh:maxCount 1 ] . + + +:TranscriptionSchemeTagShape ; + a sh:NodeShape ; + sh:targetClass dmlex:TranscriptionSchemeTag ; + sh:closed false ; + sh:property [ + sh:path dmlex:inflectedForm ; + sh:class dmlex:InflectedForm ] ; + sh:property [ + sh:path dmlex:tag ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:description ; + sh:minCount 0 ; + sh:maxCount 1 ] . + + +:RelationShape ; + a sh:NodeShape ; + sh:targetClass dmlex:Relation ; + sh:closed false ; + sh:property [ + sh:path dmlex:description ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:type ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:member ; + sh:minCount 2 ; + sh:class dmlex:Member ] . + + +:MemberShape ; + a sh:NodeShape ; + sh:targetClass dmlex:Member ; + sh:closed false ; + sh:property [ + sh:path dmlex:listingOrder ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:memberID ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:obverseListingOrder ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:role ; + sh:minCount 0 ; + sh:maxCount 1 ] . + + +:RelationTypeShape ; + a sh:NodeShape ; + sh:targetClass dmlex:RelationType ; + sh:closed false ; + sh:property [ + sh:path dmlex:description ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:type ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:scope ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:memberType ; + sh:class dmlex:MemberType ] . + + +:MemberTypeShape ; + a sh:NodeShape ; + sh:targetClass dmlex:MemberType ; + sh:closed false ; + sh:property [ + sh:path dmlex:description ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:type ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:role ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:min ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:max ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:action ; + sh:minCount 0 ; + sh:maxCount 1 ] . + + +:PlaceholderMarkerShape ; + a sh:NodeShape ; + sh:targetClass dmlex:PlaceholderMarker ; + sh:closed false ; + sh:property [ + sh:path dmlex:startIndex ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:endIndex ; + sh:minCount 1 ; + sh:maxCount 1 ] . + + +:HeadwordMarkerShape ; + a sh:NodeShape ; + sh:targetClass dmlex:HeadwordMarker ; + sh:closed false ; + sh:property [ + sh:path dmlex:startIndex ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:endIndex ; + sh:minCount 1 ; + sh:maxCount 1 ] . + + +:CollocateMarkerShape ; + a sh:NodeShape ; + sh:targetClass dmlex:CollocateMarker ; + sh:closed false ; + sh:property [ + sh:path dmlex:label ; + sh:class dmlex:Label ] ; + sh:property [ + sh:path dmlex:lemma ; + sh:minCount 0 ; + sh:maxCount 1 ] . + + +:EtymologyShape ; + a sh:NodeShape ; + sh:targetClass dmlex:Etymology ; + sh:closed false ; + sh:property [ + sh:path dmlex:listingOrder ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:description ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:etymon ; + sh:class dmlex:Etymon ] . + + +:EtymonShape ; + a sh:NodeShape ; + sh:targetClass dmlex:Etymon ; + sh:closed false ; + sh:property [ + sh:path dmlex:listingOrder ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:type ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:when ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:note ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:etymonUnit ; + sh:minCount 1 ; + sh:class dmlex:EtymonUnit ] ; + sh:property [ + sh:path dmlex:translation ; + sh:minCount 0 ; + sh:maxCount 1 ] . + + +:EtymonUnitShape ; + a sh:NodeShape ; + sh:targetClass dmlex:EtymonUnit ; + sh:closed false ; + sh:property [ + sh:path dmlex:listingOrder ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:language ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:partOfSpeech ; + sh:class dmlex:PartOfSpeech ] ; + sh:property [ + sh:path dmlex:text ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:translation ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:reconstructed ; + sh:minCount 0 ; + sh:maxCount 1 ] . + + +:EtymonTypeShape ; + a sh:NodeShape ; + sh:targetClass dmlex:EtymonType ; + sh:closed false ; + sh:property [ + sh:path dmlex:description ; + sh:minCount 0 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:type ; + sh:minCount 1 ; + sh:maxCount 1 ] . + + +:EtymonLanguageShape ; + a sh:NodeShape ; + sh:targetClass dmlex:EtymonLanguage ; + sh:closed false ; + sh:property [ + sh:path dmlex:langCode ; + sh:minCount 1 ; + sh:maxCount 1 ] ; + sh:property [ + sh:path dmlex:displayName ; + sh:minCount 0 ; + sh:maxCount 1 ] . + diff --git a/dmlex-v1.0/specification/serializations/RDF/verify_shacl.sh b/dmlex-v1.0/specification/serializations/RDF/verify_shacl.sh new file mode 100644 index 00000000..ad02975f --- /dev/null +++ b/dmlex-v1.0/specification/serializations/RDF/verify_shacl.sh @@ -0,0 +1,7 @@ +# Run in dmlex-v1.0/specification/serializations/RDF/ + +for f in `ls ../../examples/examples/source/*.rdf` +do + echo "Validating $f" + pyshacl -s ontology/dmlex.shacl -df turtle $f -e ontology/dmlex.ttl -i rdfs +done From 891482b7c171c70182a7222bc7367fb7687c6d42 Mon Sep 17 00:00:00 2001 From: "John P. McCrae" Date: Mon, 11 Mar 2024 12:49:04 +0000 Subject: [PATCH 3/3] Update SHACL --- .../serializations/RDF/ontology/dmlex.shacl | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex.shacl b/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex.shacl index 10fdadb0..21591698 100644 --- a/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex.shacl +++ b/dmlex-v1.0/specification/serializations/RDF/ontology/dmlex.shacl @@ -53,7 +53,7 @@ sh:path dmlex:etymonLanguage ; sh:class dmlex:EtymonLanguage ] ; sh:property [ - sh:path dmlex:language ; + sh:path dmlex:langCode ; sh:minCount 1 ; sh:maxCount 1 ] . @@ -145,8 +145,7 @@ sh:property [ sh:path dmlex:indicator ; sh:minCount 0 ; - sh:maxCount 1 ; - sh:class dmlex:Indicator ] ; + sh:maxCount 1 ] ; sh:property [ sh:path dmlex:definition ; sh:class dmlex:Definition ] ; @@ -299,9 +298,7 @@ sh:minCount 1 ; sh:maxCount 1 ] ; sh:property [ - sh:path dmlex:language ; - sh:minCount 0 ; - sh:maxCount 1 ] ; + sh:path dmlex:langCode ] ; sh:property [ sh:path dmlex:partOfSpeech ; sh:class dmlex:PartOfSpeech ] ; @@ -328,9 +325,7 @@ sh:targetClass dmlex:HeadwordExplanation ; sh:closed false ; sh:property [ - sh:path dmlex:language ; - sh:minCount 0 ; - sh:maxCount 1 ] ; + sh:path dmlex:langCode ] ; sh:property [ sh:path dmlex:text ; sh:minCount 1 ; @@ -344,9 +339,7 @@ sh:property [ sh:path dmlex:listingOrder ] ; sh:property [ - sh:path dmlex:language ; - sh:minCount 0 ; - sh:maxCount 1 ] ; + sh:path dmlex:langCode ] ; sh:property [ sh:path dmlex:label ; sh:class dmlex:Label ] ; @@ -513,12 +506,12 @@ sh:minCount 1 ; sh:maxCount 1 ] ; sh:property [ - sh:path dmlex:memberID ; + sh:path dmlex:ref ; sh:minCount 1 ; sh:maxCount 1 ] ; sh:property [ sh:path dmlex:obverseListingOrder ; - sh:minCount 1 ; + sh:minCount 0 ; sh:maxCount 1 ] ; sh:property [ sh:path dmlex:role ; @@ -561,7 +554,7 @@ sh:maxCount 1 ] ; sh:property [ sh:path dmlex:role ; - sh:minCount 1 ; + sh:minCount 0 ; sh:maxCount 1 ] ; sh:property [ sh:path dmlex:min ; @@ -674,9 +667,7 @@ sh:minCount 1 ; sh:maxCount 1 ] ; sh:property [ - sh:path dmlex:language ; - sh:minCount 1 ; - sh:maxCount 1 ] ; + sh:path dmlex:langCode ] ; sh:property [ sh:path dmlex:partOfSpeech ; sh:class dmlex:PartOfSpeech ] ;