-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcookie.lisp
30 lines (23 loc) · 1015 Bytes
/
cookie.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
;;;; Martin Kersner, m.kersner@gmail.com
;;;; 2017/06/09
(defclass cookie (suite)
((hypos-lst :initarg :hypos)
(hypos :accessor get-hypos)))
(defmethod initialize-instance :after ((cp cookie) &key)
(let ((hypos-lst (slot-value cp 'hypos-lst))
(hypos (make-hash-table))
(hypos-part nil))
(mapcar #'(lambda (hypo) (progn
(setq hypos-part (make-hash-table))
(mapcar #'(lambda (d)
(setf (gethash (car d) hypos-part) (cadr d)))
(cadr hypo))
(setf (gethash (first hypo) hypos) hypos-part)))
hypos-lst)
(maphash #'(lambda (hypo val-prob-lst) (set-value cp hypo 1)) hypos)
(setf (get-hypos cp) hypos)
(normalize cp)))
(defmethod likelihood ((cp cookie) data hypo)
(multiple-value-setq (h hypos-found) (gethash hypo (get-hypos cp)))
(multiple-value-setq (prob prob-found) (gethash data h))
prob)