From d4f9fc2b0813610cb762d9a4014557a53aeaf435 Mon Sep 17 00:00:00 2001 From: Adrian Medina Date: Tue, 19 Dec 2023 17:34:50 -0500 Subject: [PATCH] infer cardinality of one for owl:FunctionalProperty --- resources/net/wikipunk/ext/json-schema.ttl | 44 +++++++++++----------- src/clj/net/wikipunk/datomic/boot.clj | 20 ++-------- src/cljc/net/wikipunk/rdf/jsonschema.cljc | 44 +++++++++++----------- 3 files changed, 47 insertions(+), 61 deletions(-) diff --git a/resources/net/wikipunk/ext/json-schema.ttl b/resources/net/wikipunk/ext/json-schema.ttl index 7560a9b..9600b00 100644 --- a/resources/net/wikipunk/ext/json-schema.ttl +++ b/resources/net/wikipunk/ext/json-schema.ttl @@ -114,7 +114,7 @@ ### https://www.w3.org/2019/wot/json-schema#const - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "const" ; @@ -125,7 +125,7 @@ ### https://www.w3.org/2019/wot/json-schema#default - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "default" ; @@ -148,7 +148,7 @@ ### https://www.w3.org/2019/wot/json-schema#maxItems - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "maxItems" ; @@ -161,7 +161,7 @@ ### https://www.w3.org/2019/wot/json-schema#maximum - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "maximum" ; @@ -175,7 +175,7 @@ ### https://www.w3.org/2019/wot/json-schema#exclusiveMaximum - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "exclusiveMaximum" ; @@ -189,7 +189,7 @@ ### https://www.w3.org/2019/wot/json-schema#minItems - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "minItems" ; @@ -200,7 +200,7 @@ ### https://www.w3.org/2019/wot/json-schema#multipleOf - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "multipleOf" ; @@ -211,7 +211,7 @@ ### https://www.w3.org/2019/wot/json-schema#minimum - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "minimum" ; @@ -224,7 +224,7 @@ ### https://www.w3.org/2019/wot/json-schema#exclusiveMinimum - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "exclusiveMinimum" ; @@ -237,7 +237,7 @@ ### https://www.w3.org/2019/wot/json-schema#maxLength - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "maxLength" ; @@ -248,7 +248,7 @@ ### https://www.w3.org/2019/wot/json-schema#minLength - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "minLength" ; @@ -259,14 +259,14 @@ ### https://www.w3.org/2019/wot/json-schema#pattern - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "pattern" ; rdfs:comment "Provides a regular expression to express constraints of the string value. The regular expression must follow the ECMA 262 dialect."@en ; schema:domainIncludes :StringSchema ; - rdfs:range xsd:nonNegativeInteger . + rdfs:range xsd:string . ### https://www.w3.org/2019/wot/json-schema#required @@ -283,7 +283,7 @@ ### https://www.w3.org/2019/wot/json-schema#readOnly - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "readOnly" ; @@ -292,7 +292,7 @@ schema:domainIncludes :DataSchema ; rdfs:range xsd:boolean . - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "format" ; @@ -302,7 +302,7 @@ rdfs:range xsd:string . - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "contentEncoding" ; @@ -311,7 +311,7 @@ schema:domainIncludes :StringSchema ; rdfs:range xsd:string . - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "contentMediaType" ; @@ -323,7 +323,7 @@ ### https://www.w3.org/2019/wot/json-schema#writeOnly - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "writeOnly" ; @@ -335,7 +335,7 @@ ### https://www.w3.org/2019/wot/json-schema#description - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "propertyName" ; @@ -429,7 +429,7 @@ ### https://www.w3.org/2019/wot/json-schema#uniqueItems - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "uniqueItems" ; @@ -440,7 +440,7 @@ ### https://www.w3.org/2019/wot/json-schema#additionalProperties - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "additionalProperties" ; @@ -451,7 +451,7 @@ ### https://www.w3.org/2019/wot/json-schema#nullable - rdf:type owl:DatatypeProperty ; + rdf:type owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:label "nullable" ; diff --git a/src/clj/net/wikipunk/datomic/boot.clj b/src/clj/net/wikipunk/datomic/boot.clj index 9633199..4464c44 100644 --- a/src/clj/net/wikipunk/datomic/boot.clj +++ b/src/clj/net/wikipunk/datomic/boot.clj @@ -240,6 +240,8 @@ [_] nil) +(defmethod rdf/infer-datomic-cardinality :owl/FunctionalProperty [_] :db.cardinality/one) + (defmethod rdf/infer-datomic-type :rdfa/uri [_] :db.type/string) (defmethod rdf/infer-datomic-cardinality :rdfa/uri [_] :db.cardinality/one) (defmethod rdf/infer-datomic-unique :rdfa/uri [_] :db.unique/identity) @@ -257,22 +259,6 @@ (defmethod rdf/infer-datomic-type :rdf/language [_] :db.type/string) (defmethod rdf/infer-datomic-cardinality :rdf/language [_] :db.cardinality/one) -(defmethod rdf/infer-datomic-cardinality :jsonschema/exclusiveMinimum [_] :db.cardinality/one) -(defmethod rdf/infer-datomic-cardinality :jsonschema/exclusiveMaximum [_] :db.cardinality/one) -(defmethod rdf/infer-datomic-cardinality :jsonschema/propertyName [_] :db.cardinality/one) -(defmethod rdf/infer-datomic-cardinality :jsonschema/minimum [_] :db.cardinality/one) -(defmethod rdf/infer-datomic-cardinality :jsonschema/maximum [_] :db.cardinality/one) -(defmethod rdf/infer-datomic-cardinality :jsonschema/minItems [_] :db.cardinality/one) -(defmethod rdf/infer-datomic-cardinality :jsonschema/maxItems [_] :db.cardinality/one) -(defmethod rdf/infer-datomic-cardinality :jsonschema/minLength [_] :db.cardinality/one) -(defmethod rdf/infer-datomic-cardinality :jsonschema/maxLength [_] :db.cardinality/one) -(defmethod rdf/infer-datomic-cardinality :jsonschema/multipleOf [_] :db.cardinality/one) -(defmethod rdf/infer-datomic-cardinality :jsonschema/readOnly [_] :db.cardinality/one) -(defmethod rdf/infer-datomic-cardinality :jsonschema/uniqueItems [_] :db.cardinality/one) -(defmethod rdf/infer-datomic-cardinality :jsonschema/writeOnly [_] :db.cardinality/one) -(defmethod rdf/infer-datomic-cardinality :jsonschema/nullable [_] :db.cardinality/one) -(defmethod rdf/infer-datomic-cardinality :jsonschema/additionalProperties [_] :db.cardinality/one) - (defmethod rdf/infer-datomic-cardinality :owl/propertyChainAxiom [_] :db.cardinality/one) (defmethod rdf/infer-datomic-type :rdf/Property @@ -306,7 +292,7 @@ (when unionOf (some rdf/infer-datomic-type unionOf)))) -#_(defmethod rdf/infer-datomic-type :rdfs/Literal [_] :db.type/string) +(defmethod rdf/infer-datomic-type :rdfs/Literal [_] :db.type/string) (prefer-method rdf/infer-datomic-type :rdfs/Literal :rdfs/Datatype) (defmethod rdf/infer-datomic-type :rdfs/seeAlso [_] :db.type/ref) diff --git a/src/cljc/net/wikipunk/rdf/jsonschema.cljc b/src/cljc/net/wikipunk/rdf/jsonschema.cljc index 1c0d1f7..a7d314e 100644 --- a/src/cljc/net/wikipunk/rdf/jsonschema.cljc +++ b/src/cljc/net/wikipunk/rdf/jsonschema.cljc @@ -102,7 +102,7 @@ (def additionalProperties {:db/ident :jsonschema/additionalProperties, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value @@ -135,7 +135,7 @@ (def const {:db/ident :jsonschema/const, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value "Provides a constant value."}, :rdfs/label "const", @@ -143,7 +143,7 @@ (def contentEncoding {:db/ident :jsonschema/contentEncoding, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value @@ -154,7 +154,7 @@ (def contentMediaType {:db/ident :jsonschema/contentMediaType, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value @@ -165,7 +165,7 @@ (def default {:db/ident :jsonschema/default, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value @@ -183,7 +183,7 @@ (def exclusiveMaximum {:db/ident :jsonschema/exclusiveMaximum, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value @@ -196,7 +196,7 @@ (def exclusiveMinimum {:db/ident :jsonschema/exclusiveMinimum, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value @@ -209,7 +209,7 @@ (def format {:db/ident :jsonschema/format, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value @@ -230,7 +230,7 @@ (def maxItems {:db/ident :jsonschema/maxItems, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value @@ -241,7 +241,7 @@ (def maxLength {:db/ident :jsonschema/maxLength, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value @@ -252,7 +252,7 @@ (def maximum {:db/ident :jsonschema/maximum, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value @@ -265,7 +265,7 @@ (def minItems {:db/ident :jsonschema/minItems, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value @@ -276,7 +276,7 @@ (def minLength {:db/ident :jsonschema/minLength, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value @@ -287,7 +287,7 @@ (def minimum {:db/ident :jsonschema/minimum, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value @@ -300,7 +300,7 @@ (def multipleOf {:db/ident :jsonschema/multipleOf, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value @@ -312,7 +312,7 @@ (def nullable {:db/ident :jsonschema/nullable, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value @@ -334,13 +334,13 @@ (def pattern {:db/ident :jsonschema/pattern, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value "Provides a regular expression to express constraints of the string value. The regular expression must follow the ECMA 262 dialect."}, :rdfs/label "pattern", - :rdfs/range :xsd/nonNegativeInteger, + :rdfs/range :xsd/string, :schema/domainIncludes :jsonschema/StringSchema}) (def properties @@ -354,7 +354,7 @@ (def propertyName {:db/ident :jsonschema/propertyName, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value @@ -365,7 +365,7 @@ (def readOnly {:db/ident :jsonschema/readOnly, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value @@ -387,7 +387,7 @@ (def uniqueItems {:db/ident :jsonschema/uniqueItems, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value @@ -398,7 +398,7 @@ (def writeOnly {:db/ident :jsonschema/writeOnly, - :rdf/type :owl/DatatypeProperty, + :rdf/type #{:owl/DatatypeProperty :owl/FunctionalProperty}, :rdfs/comment {:rdf/language "en", :rdf/value