Strong suspicion I've made the same changes on Ploughwright and on Mason

But I'll get them all into Git then sort them out.
This commit is contained in:
Simon Brooke 2025-08-21 15:02:03 +01:00
parent ae26a393e8
commit 792ad6fbfa

View file

@ -2,7 +2,7 @@
"Knowledge base to use in testing." "Knowledge base to use in testing."
(:require (:require
[arboretum.dengine.case :refer [make-case]] [arboretum.dengine.case :refer [make-case]]
[arboretum.dengine.core :refer [add-dtree! add-feature!]] [arboretum.dengine.core :refer [add-dtree!]]
[arboretum.dengine.feature :refer [make-feature]] [arboretum.dengine.feature :refer [make-feature]]
[arboretum.dengine.kb :refer [!kb]] [arboretum.dengine.kb :refer [!kb]]
[arboretum.dengine.node :refer [make-node]] [arboretum.dengine.node :refer [make-node]]
@ -12,7 +12,7 @@
(def testkb (def testkb
(KBImpl. {:case-1 (KBImpl. {:case-1
(make-case :case-1 "Mrs Norah Trellis" (make-case :case-1 "Mrs Norah Trellis"
{:married {:value true {:married {:value true
:authority :user :authority :user
:reason "I have been told that married is true of Mrs Norah Trellis"} :reason "I have been told that married is true of Mrs Norah Trellis"}
@ -37,7 +37,20 @@
(reset! !kb testkb) (reset! !kb testkb)
(add-feature! "Is entitled to Widows' Allowance" :is-entitled-to-widows-allowance false nil) ;; TODO:
;; we can't add a node in `add-feature!` since creating the root node requires
;; that the feature already exists. So the 'rootnode' argument to `add-feature`
;; and make-feature is not useful and should be deleted. We also need to test
;; when adding a dtree to an existing feature that the rootnode references that
;; feature.
;; OK, it's worse than that. We can't persist and restore a knowledge base in
;; which features are directly linked from DTree nodes, since then we would
;; (probably) create multiple copies of the feature when reloading. So probably
;; the node should only hold the id of the feature, not a direct link.
;; This does mean, however, that the node could be made at feature creation
;; time.
(add-dtree! :is-entitled-to-widows-allowance (add-dtree! :is-entitled-to-widows-allowance
(make-node :is-entitled-to-widows-allowance false (make-node :is-entitled-to-widows-allowance false
@ -65,7 +78,7 @@
"Although your late husband's contributions were sufficient, we understand you have a pension.") "Although your late husband's contributions were sufficient, we understand you have a pension.")
(list (make-node :under-pension-age-when-bereaved true (list (make-node :under-pension-age-when-bereaved true
"Because you were under pensionable age when bereaved, you are entitled to Widows' Allowance") "Because you were under pensionable age when bereaved, you are entitled to Widows' Allowance")
(make-node :husband-not-entitled-to-cata-rp true (make-node :husband-not-entitled-to-cata-rp true
"Because your husband was not entitled to a Category A Retirement Pension, you are entitled to Widows' Allowance"))))))) "Because your husband was not entitled to a Category A Retirement Pension, you are entitled to Widows' Allowance")))))))
(pp/pprint @!kb) (pp/pprint @!kb)