72 lines
5 KiB
Clojure
72 lines
5 KiB
Clojure
(ns dengine.test-kb
|
|
"Knowledge base to use in testing."
|
|
(:require
|
|
[arboretum.dengine.case :refer [make-case]]
|
|
[arboretum.dengine.core :refer [add-dtree! add-feature!]]
|
|
[arboretum.dengine.feature :refer [make-feature]]
|
|
[arboretum.dengine.kb :refer [!kb]]
|
|
[arboretum.dengine.node :refer [make-node]]
|
|
[clojure.pprint :as pp])
|
|
(:import
|
|
[arboretum.dengine.kb KBImpl]))
|
|
|
|
(def testkb
|
|
(KBImpl. {:case-1
|
|
(make-case :case-1 "Mrs Norah Trellis"
|
|
{:married {:value true
|
|
:authority :user
|
|
:reason "I have been told that married is true of Mrs Norah Trellis"}
|
|
:divorced {:value false
|
|
:authority :default
|
|
:reason "I assumed that divorced is false of Mrs Norah Trellis"}})}
|
|
{:divorced (make-feature "Divorced" :divorced false nil)
|
|
:married (make-feature "Married" :married false nil)
|
|
:widowed (make-feature "Widowed" :widowed false nil)
|
|
:is-entitled-to-widows-allowance (make-feature "Is entitled to Widows' Allowance"
|
|
:is-entitled-to-widows-allowance
|
|
false nil)
|
|
:satisfies-conditions-for-widows-allowance (make-feature "Satisfies conditions for Widows' Allowance"
|
|
:satisfies-conditions-for-widows-allowance
|
|
false nil)
|
|
:gt-26-weeks-bereaved (make-feature "> 26 weeks bereaved" :gt-26-weeks-bereaved
|
|
false nil)
|
|
:killed-husband (make-feature "Killed husband" :killed-husband false nil)
|
|
:dead (make-feature "Dead" :dead false nil)
|
|
:in-prison (make-feature "In prison" :in-prison false nil)
|
|
:husbands-contributions-qualify (make-feature "Husband's contributions qualify" :husbands-contributions-qualify true nil)}))
|
|
|
|
(reset! !kb testkb)
|
|
|
|
(add-feature! "Is entitled to Widows' Allowance" :is-entitled-to-widows-allowance false nil)
|
|
|
|
(add-dtree! :is-entitled-to-widows-allowance
|
|
(make-node :is-entitled-to-widows-allowance false
|
|
"I have not been able to determine that you are entitled to Widows' Allowance."
|
|
(list (make-node :satisfies-conditions-for-widows-allowance true
|
|
"You satisfy all the conditions for Widows' Allowance."
|
|
(list (make-node :gt-26-weeks-bereaved false
|
|
"You no longer qualify for Widows' Allowance as it is more than 26 weeks since you were bereaved")
|
|
(make-node :killed-husband false
|
|
"You do not qualify for Widows' Allowance as we understand that you killed your husband.")
|
|
(make-node :dead false
|
|
"The subject of this application does not qualify for Widows' Allowance as we understand that she is dead")
|
|
(make-node :in-prison false
|
|
"You do not qualify for Widows' Allowance while you are in prison")
|
|
(make-node :living-with-partner false
|
|
"You do not qualify for Widows' Allowance as we understand that you have a new partner.")
|
|
)))))
|
|
|
|
(add-dtree! :satisfies-conditions-for-widows-allowance
|
|
(make-node :satisfies-conditions-for-widows-allowance false
|
|
"I have not been able to determine that you satisfy the conditions for Widows' Allowance."
|
|
(list (make-node :widowed false
|
|
"Although you are a widow, your late husband's National Insurance contributions were not sufficient to qualify."
|
|
(list (make-node :husbands-contributions-qualify false
|
|
"Although your late husband's contributions were sufficient, we understand you have a pension.")
|
|
(list (make-node :under-pension-age-when-bereaved true
|
|
"Because you were under pensionable age when bereaved, you are entitled to Widows' Allowance")
|
|
(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")))))))
|
|
|
|
(pp/pprint @!kb)
|