Skip to content

Commit 3ce96b8

Browse files
authored
Testing property/class structuring. (#4628)
* Add a test to catch Class/Property mismatch in equivalences. * Fix all Class/Property conflicts. This was done by inspecting the type of the referenced object in case it came from another onltology. * Adding tests for checking the proper class/properrty structuring. This adds some tests to verify that property hierarchies are done using property-related relations, and class hierarchies are done using class-related relations.
1 parent cbb7a1a commit 3ce96b8

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

data/schema.ttl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4241,7 +4241,6 @@ See also the <a href="/docs/hotels.html">dedicated document on the use of schema
42414241
:address a rdf:Property ;
42424242
rdfs:label "address" ;
42434243
rdfs:comment "Physical address of the item." ;
4244-
owl:equivalentProperty gs1:PostalAddress ;
42454244
:domainIncludes :GeoCoordinates,
42464245
:GeoShape,
42474246
:Organization,
@@ -4253,7 +4252,6 @@ See also the <a href="/docs/hotels.html">dedicated document on the use of schema
42534252
:addressCountry a rdf:Property ;
42544253
rdfs:label "addressCountry" ;
42554254
rdfs:comment """The country. Recommended to be in 2-letter [ISO 3166-1 alpha-2](http://en.wikipedia.org/wiki/ISO_3166-1) format, for example "US". For backward compatibility, a 3-letter [ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) country code such as "SGP" or a full country name such as "Singapore" can also be used.""" ;
4256-
owl:equivalentProperty gs1:Country ;
42574255
:domainIncludes :DefinedRegion,
42584256
:GeoCoordinates,
42594257
:GeoShape,
@@ -6487,7 +6485,6 @@ In the context of [[ShippingService]], use the [[ServicePeriod]] format, that co
64876485
:hasDeliveryMethod a rdf:Property ;
64886486
rdfs:label "hasDeliveryMethod" ;
64896487
rdfs:comment "Method used for delivery or shipping." ;
6490-
owl:equivalentProperty unece:TransportMethod ;
64916488
:domainIncludes :DeliveryEvent,
64926489
:ParcelDelivery ;
64936490
:rangeIncludes :DeliveryMethod .
@@ -7927,7 +7924,6 @@ Note: for historical reasons, any textual label and formal code provided as a li
79277924
rdfs:label "paymentMethod" ;
79287925
rdfs:comment "The name of the credit card or other method of payment for the order." ;
79297926
rdfs:subPropertyOf fibo-fbc-pas-fpas:hasPaymentMechanism ;
7930-
owl:equivalentProperty unece:PaymentMeans ;
79317927
:domainIncludes :Invoice,
79327928
:Order ;
79337929
:rangeIncludes :PaymentMethod,

software/tests/test_graphs.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,18 +539,53 @@ def test_EnumerationWithoutEnums(self):
539539
""",
540540
error_message="Enumeration Type without Enumeration value")
541541

542-
def test_owlEquivalences(self):
542+
def test_illegalOwlClassPropertyMixup(self):
543543
self.assertNoMatch("""
544544
PREFIX owl: <http://www.w3.org/2002/07/owl#>
545545
SELECT ?term ?equivType WHERE {
546546
?term owl:equivalentClass ?equivType .
547-
FILTER EXISTS { ?term owl:equivalentProperty ?equivType . }
547+
?term owl:equivalentProperty ?equivType .
548548
}
549549
ORDER BY ?term
550550
""",
551551
error_message="Equivalence cannot hold for both Class and Property!",
552552
row_pattern="Term '%(term)s' is both equivalent Class and Property of %(equivType)s")
553553

554+
self.assertNoMatch("""
555+
PREFIX owl: <http://www.w3.org/2002/07/owl#>
556+
SELECT ?cls ?prop ?equivType WHERE {
557+
?cls owl:equivalentClass ?equivType .
558+
?prop owl:equivalentProperty ?equivType .
559+
}
560+
ORDER BY ?cls
561+
""",
562+
error_message="A type cannot be both equivalentClass and equivalentProperty!",
563+
row_pattern="Type '%(equivType)s' cannot be both an equivalent Class (with %(cls)s) and Property of (with %(prop)s)")
564+
565+
def test_properClassPropertyStructuring(self):
566+
self.assertNoMatch("""
567+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
568+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
569+
PREFIX owl: <http://www.w3.org/2002/07/owl#>
570+
571+
SELECT ?term ?target WHERE {
572+
# Define the combinations of type and predicate to look for
573+
VALUES (?type ?predicate) {
574+
(rdfs:Class rdfs:subPropertyOf)
575+
(rdfs:Class owl:equivalentProperty)
576+
(rdfs:Property rdfs:subClassOf)
577+
(rdfs:Property owl:equivalentClass)
578+
}
579+
580+
# Apply the pattern once using the values above
581+
?term a ?type .
582+
?term ?predicate ?target .
583+
584+
} ORDER BY ?term
585+
""",
586+
error_message="A type cannot be a Class (Property) and also be a subPropertyOf (subClassOf) or something!",
587+
row_pattern="'%(term)s' is a Class/Property and also a subPropertyOf/subClassOf %(target)s")
588+
554589

555590
# TODO: Unwritten tests (from basics; easier here?)
556591
#

0 commit comments

Comments
 (0)