-
Notifications
You must be signed in to change notification settings - Fork 8
5.11 Ontologies
Claude Roux edited this page Jan 27, 2022
·
3 revisions
An ontology is a defined as a set of concepts that can be combined one the other with the following operators:
- eq : compare two concepts together
- & : intersection of concepts
- | : union of concepts
- ^ : exclusive union of concepts (same concepts are discarded)
- &~ : We keep only the concepts that the concepts does not have
- ~ : The set of all the concepts that are different from the current concept
Each ontology exposes by default the _absurd concept, which is the empty set.
Important : this ontology is by no way hierarchical, as in traditional ontologies. Concepts can be combined throughout the whole ontology, whatever their place or definition.
(ontology_absurd (h) Returns the '_absurd' concept for this ontology)
(ontology_find (h conc) Checks if a concept list has a name in the ontology)
(ontology_ontology (conc) Returns the ontology in which this concept is declared)
(ontology (name) Creates an ontology)
(ontology_list (conc) Returns the list of concepts stored in concepts)
(ontology_remove (conc a) Removes a concept from another concept definition in the ontology)
(ontology_add (conc a) Enriches the concept definition in the ontology with the other concept)
(ontology_intersect (conc a) Checks if two concepts have concepts in common)
(ontology_contain (large_conc conc) Check if large_conc contains conc)
(ontology_concept (h name) Returns the concept associated with this name)
(ontology_all (h) Returns the list of all concepts)
(ontology_absurdp (conc) Checks if the concept is '_absurd')
(ontology_create (h name (conc)) Creates a new concept definition with a name. The concept description can also be provided)
; We create an ontology: colors
(setq h (ontology "colors"))
; Our top concept is: color
(setq color (ontology_create h "color"))
; different colors, which all share the concept color
(setq red (ontology_create h "red" color))
(setq green (ontology_create h "green" color))
(setq blue (ontology_create h "blue" color))
(setq violet (ontology_create h "violet" color))
(setq indigo (ontology_create h "indigo" color))
(setq yellow (ontology_create h "yellow" color))
(setq orange (ontology_create h "orange" color))
; We can also combine two color concepts together
(ontology_add violet (list color indigo))
(ontology_add yellow (list color indigo))
; we can intersect two concepts
(println (ontology_list (& violet yellow)))
(println (ontology_list (| violet yellow)))
; We can remove a concept from a concept definition
(ontology_remove violet color)
(println "Sans color:" (ontology_list violet))
; These two calls return the same value
(println (ontology_concept h "orange") orange)
; We create a color black by combining red, green and blue
(ontology_create h "black" (| red green blue))
(println (ontology_list (ontology_concept h "black")))
; We display all concepts in the ontology
(println (ontology_all h))
; We can compare concepts
(if (eq
(& red (| red green))
(ontology_concept h "red")
)
(println 'ok)
(println 'non)
)
; When an intersection is empty we return _absurd
(if (ontology_absurdp (& red green))
(println 'Oui)
(println 'Non)
)
; In this case yellow is just yellow
(ontology_remove yellow yellow)