Skip to content

Commit

Permalink
refactor: Remove remnants of previous naming
Browse files Browse the repository at this point in the history
  • Loading branch information
ngrewe committed Feb 18, 2024
1 parent fc3e313 commit 86ab983
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 75 deletions.
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ dependencies {
clojure {
builds {
main {
aotNamespaces.add('tqc.base')
aotNamespaces.add('tqc.core')
aotNamespaces.add('tqc.writer')
aotNamespaces.add('de.halbordnung.ontologies.tqme.base')
aotNamespaces.add('de.halbordnung.ontologies.tqme.core')
aotNamespaces.add('de.halbordnung.ontologies.tqme.writer')
reflection = 'warn'
}
}
}

jar {
manifest.attributes("Main-Class": "tqc.writer")
manifest.attributes("Main-Class": "de.halbordnung.ontologies.tqme.writer")
}

shadowJar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from(sourceSets["test"].output)
archiveBaseName.set("tqc")
archiveBaseName.set("tqme")
mergeServiceFiles()
manifest {
attributes("Main-Class": "tqc.writer")
attributes("Main-Class": "de.halbordnung.ontologies.tqme.writer")
}
}

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
rootProject.name = 'tqc'
rootProject.name = 'tqme'

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns ^{:doc "BFO import layer and general declarations for TQCs."
(ns ^{:doc "BFO import layer and general declarations for TQMEs."
:author "Niels Grewe"}
tqc.base
de.halbordnung.ontologies.tqme.base
(:require [clj-uuid :as uuid]
[tawny.read :as r]
[tawny.memorise]
Expand All @@ -13,7 +13,8 @@
(defn resource-iri "Get a reference to the local BFO copy" ^IRI []
(IRI/create (clojure.java.io/resource "bfo.owl")))

(defn -scoped "Generate a v5 UUID in the tqc namespace" [^String n]
(defn -scoped "Generate a v5 UUID in the tqme namespace" [^String n]
; The namespace here must be kept as is in order to keep IRIs stable
(uuid/v5 (uuid/v5 uuid/+namespace-url+ "http://www.halbordnung.de/ontologies/tqc.owl")
n))
(defdontfn iri-generate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
(ns ^{:doc "Core definitions for temporally qualified material entities."
:author "Niels Grewe"}
tqc.core
(:require [tqc.base :as b]
de.halbordnung.ontologies.tqme.core
(:require [de.halbordnung.ontologies.tqme.base :as b]
[tawny.owl :as o])
(:use [tawny.owl]))

(defn- ml "Generates a multi line string" [& strings] (clojure.string/join "\n" strings))

(defontology tqc
(defontology tqme-ontology
:iri "http://www.halbordnung.de/ontologies/tqme.owl"
:prefix "tqc:"
:prefix "tqme:"
:iri-gen b/iri-generate)

(owl-import b/bfo)
Expand Down Expand Up @@ -63,36 +63,36 @@
(add-superclass b/material_entity (owl-some b/has_history b/history))


(defoproperty has-min-tqc
(defoproperty has-min-tqme
:label "has minimal temporally qualified material entity"
:domain tqme
:comment (ml "The relation between a material entity (of temporally maximal qualification) and one of its minimal ones."
"Since minimally qualified material entites are themselves material entities, they may themselves be in the domain of this relation."
)
)

(add-subchain has-min-tqc [b/has_history b/has_occurrent_part phase-of])
(add-subchain has-min-tqme [b/has_history b/has_occurrent_part phase-of])

(defoproperty min-tqc-of
(defoproperty min-tqme-of
:label "minimal temporally qualified material entity of"
:range b/material_entity
:inverse has-min-tqc)
:inverse has-min-tqme)

(defoproperty has-max-tqc
(defoproperty has-max-tqme
:label "has maximal material entity"
:range b/material_entity
:comment "the relation between a temporally qualified material entity and a maximal one"
)

(add-subchain has-max-tqc [has-phase b/part_of_occurrent b/history_of])
(add-subchain has-max-tqme [has-phase b/part_of_occurrent b/history_of])

(defoproperty max-tqc-of
(defoproperty max-tqme-of
:label "maximal material entity of"
:domain b/material_entity
:inverse has-max-tqc)
:inverse has-max-tqme)

(add-subproperty min-tqc-of has-max-tqc)
(add-subproperty has-min-tqc max-tqc-of)
(add-subproperty min-tqme-of has-max-tqme)
(add-subproperty has-min-tqme max-tqme-of)

;; we steal a bit of stuff from tawny.owl to build our generators
(defmontfn
Expand Down Expand Up @@ -137,12 +137,12 @@
(defn temp
[o ctor relation class]
(owl-some o
has-max-tqc
has-max-tqme
(owl-some o
has-min-tqc
has-min-tqme
(ctor o
relation
(owl-some o min-tqc-of class)
(owl-some o min-tqme-of class)
)
)
)
Expand All @@ -151,10 +151,10 @@
(defn perm-gen
[o ctor relation class]
(owl-and
(owl-some o has-min-tqc
(ctor o relation (owl-some o min-tqc-of class)))
(owl-only o has-min-tqc
(ctor o relation (owl-some o min-tqc-of class)))
(owl-some o has-min-tqme
(ctor o relation (owl-some o min-tqme-of class)))
(owl-only o has-min-tqme
(ctor o relation (owl-some o min-tqme-of class)))

)
)
13 changes: 13 additions & 0 deletions src/main/clojure/de/halbordnung/ontologies/tqme/writer.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(ns ^{:doc "Writing the base TQME ontology"
:author "Niels Grewe"}
de.halbordnung.ontologies.tqme.writer
(:require [tawny.owl])
(:use [de.halbordnung.ontologies.tqme.core :only [tqme-ontology]])
(:gen-class))

(defn -main
"Entry point for writing the ontology"
[& args]

(tawny.owl/save-ontology tqme-ontology "tqme.owl" :owl)
(tawny.owl/save-ontology tqme-ontology "tqme.omn" :omn))
13 changes: 0 additions & 13 deletions src/main/clojure/tqc/writer.clj

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
(ns tqc.cq
(ns de.halbordnung.ontologies.tqme.cq
(:require [tawny.owl :as o]
[tawny.reasoner :as r]
[tqc.core :as c]
[tqc.base :as b])
[de.halbordnung.ontologies.tqme.core :as c]
[de.halbordnung.ontologies.tqme.base :as b]
[clojure.test]
)
[:use clojure.test]
(:import (org.semanticweb.owlapi.reasoner OWLReasoner)))

Expand All @@ -15,28 +17,28 @@
:iri "http://iri/"
:prefix "iri:"))))

(defn tqcfixture [test]
(defn tqme-fixture [test]
(binding
[r/*reasoner-progress-monitor*
(atom r/reasoner-progress-monitor-silent)]
(tawny.reasoner/reasoner-factory :hermit)
(createtestontology)
(o/owl-import to c/tqc)
(o/owl-import to c/tqme-ontology)
(test)))

(defmethod report :end-test-var [m]
(defmethod clojure.test/report :end-test-var [m]
(o/save-ontology to (clojure.core/str (-> m :var meta :name) ".owl") :owl))

(defn writetqc [test]
(o/save-ontology c/tqc "tqme.owl" :owl)
(defn write-tqme [test]
(o/save-ontology c/tqme-ontology "tqme.owl" :owl)
(test))

(defn satisfiable? [ontology expr]
(.flush ^OWLReasoner (r/reasoner ontology))
(.isSatisfiable ^OWLReasoner (r/reasoner ontology) expr))

(use-fixtures :each tqcfixture)
(use-fixtures :once writetqc)
(use-fixtures :each tqme-fixture)
(use-fixtures :once write-tqme)

(deftest tgr_cm+
(o/owl-class to "tooth"
Expand All @@ -56,17 +58,17 @@
(is (satisfiable? to (o/owl-and to "tooth"
(o/owl-some
to
c/has-min-tqc
c/has-min-tqme
(o/! to (o/owl-some to
b/part_of_continuant_at_all_times
(o/owl-some to c/min-tqc-of "organism")))))
(o/owl-some to c/min-tqme-of "organism")))))
)
"A tooth for which there is a time it is not part of any organism → OK")
(is (satisfiable? to (o/owl-and to "human"
(o/owl-some to c/has-min-tqc
(o/owl-some to c/has-min-tqme
(o/owl-some to b/has_continuant_part_at_all_times
(o/owl-some to
c/min-tqc-of
c/min-tqme-of
"tooth")))))
"A human having teeth at some time → OK"))

Expand All @@ -80,10 +82,9 @@
(o/disjoint-classes to (list "green-color" "red-color"))
(o/owl-class to "apple"
:super (o/owl-and to b/material_entity
(o/owl-some to c/has-min-tqc (o/owl-some to b/has_quality_at_all_times "green-color"))))

(o/owl-some to c/has-min-tqme (o/owl-some to b/has_quality_at_all_times "green-color"))))
(is (satisfiable? to (o/owl-and to "apple"
(o/owl-some to c/has-min-tqc (o/owl-only to b/has_quality_at_all_times
(o/owl-some to c/has-min-tqme (o/owl-only to b/has_quality_at_all_times
(o/|| to "red-color" (o/! to "color"))))))
"An apple that at some time has no other color than red → OK"))

Expand All @@ -92,8 +93,8 @@
:super b/process)
(o/owl-class to "mammal"
:super (o/owl-and to b/material_entity
(o/owl-some to c/has-max-tqc
(o/owl-some to c/has-min-tqc
(o/owl-some to c/has-max-tqme
(o/owl-some to c/has-min-tqme
(o/owl-some to b/participates_in_at_all_times "birth")))
)
)
Expand Down Expand Up @@ -223,9 +224,9 @@

(o/with-probe-axioms to
[a (o/add-subclass to
(o/owl-some to c/min-tqc-of "red-blood-cell")
(o/owl-some to c/min-tqme-of "red-blood-cell")
(o/! to (o/owl-some to b/has_continuant_part_at_all_times
(o/owl-some to c/min-tqc-of "oxygen-molecule")))
(o/owl-some to c/min-tqme-of "oxygen-molecule")))
)]
(is (not (r/consistent? to))
"There are red blood cells without oxygen molecules → owl:Nothing"))
Expand All @@ -244,13 +245,13 @@

(.flush ^OWLReasoner (r/reasoner to))
(is (r/consistent? to)
"Consistent TQC ontology for apple/colour")
"Consistent TQME ontology for apple/colour")

(o/with-probe-axioms to
[a (o/add-subclass to
(o/owl-some to c/min-tqc-of "apple")
(o/owl-some to c/min-tqme-of "apple")
(o/! to (o/owl-some to b/has_quality_at_all_times
(o/owl-some to c/min-tqc-of "colour"))))]
(o/owl-some to c/min-tqme-of "colour"))))]
(is (not (r/consistent? to))
"There are apples without a colour → owl:Nothing"))
)
Expand All @@ -264,17 +265,17 @@

(o/add-superclass to "organism"
(o/owl-and to
(o/owl-some to c/has-min-tqc (o/owl-some to b/participates_in_at_all_times "eco-process"))
(o/owl-only to c/has-min-tqc (o/owl-some to b/participates_in_at_all_times "eco-process"))
(o/owl-some to c/has-min-tqme (o/owl-some to b/participates_in_at_all_times "eco-process"))
(o/owl-only to c/has-min-tqme (o/owl-some to b/participates_in_at_all_times "eco-process"))
)
)

(is (r/consistent? to)
"Consistent TQC ontology for participation")
"Consistent TQME ontology for participation")

(o/with-probe-axioms to
[a (o/add-subclass to
(o/owl-some to c/min-tqc-of "organism")
(o/owl-some to c/min-tqme-of "organism")
(o/! to (o/owl-some to b/participates_in_at_all_times "eco-process")))]
(is (not (r/consistent? to))
"There are organisms that do not participate in any ecologic process at certain times → owl:Nothing"))
Expand All @@ -300,13 +301,13 @@
(c/perm-gen to o/owl-some b/has_continuant_part_at_all_times
"red-blood-cell"))
(is (r/consistent? to)
"Consistent TQC ontology for transitive permanent generic parthood")
"Consistent TQME ontology for transitive permanent generic parthood")
(is (not (satisfiable? to
(o/owl-and to
(o/owl-some to c/min-tqc-of "blood-volume")
(o/owl-some to c/min-tqme-of "blood-volume")
(o/! to (o/owl-some to
b/has_continuant_part_at_all_times
(o/owl-some to c/min-tqc-of "oxygen-molecule"))))
(o/owl-some to c/min-tqme-of "oxygen-molecule"))))
))
"There times where a blood volume has no oxygen molecules → owl:Nothing")
)

0 comments on commit 86ab983

Please sign in to comment.