| 1 | ;; -*- mode: lisp-interaction-mode -*-
|
|---|
| 2 |
|
|---|
| 3 | (defparameter *critics*
|
|---|
| 4 | '(("Lisa Rose"
|
|---|
| 5 | ("Lady in the Water" . 2.5)
|
|---|
| 6 | ("Snakes on a Plane" . 3.5)
|
|---|
| 7 | ("Just My Luck" . 3.0)
|
|---|
| 8 | ("Superman Returns" . 3.5)
|
|---|
| 9 | ("You, Me and Dupree" . 2.5)
|
|---|
| 10 | ("The Night Listener" . 3.0))
|
|---|
| 11 | ("Gene Seymour"
|
|---|
| 12 | ("Lady in the Water" . 3.0)
|
|---|
| 13 | ("Snakes on a Plane" . 3.5)
|
|---|
| 14 | ("Just My Luck" . 1.5)
|
|---|
| 15 | ("Superman Returns" . 5.0)
|
|---|
| 16 | ("The Night Listener" . 3.0)
|
|---|
| 17 | ("You, Me and Dupree" . 3.5))
|
|---|
| 18 | ("Michael Phillips"
|
|---|
| 19 | ("Lady in the Water" . 2.5)
|
|---|
| 20 | ("Snakes on a Plane" . 3.0)
|
|---|
| 21 | ("Superman Returns" . 3.5)
|
|---|
| 22 | ("The Night Listener" . 4.0))
|
|---|
| 23 | ("Claudia Puig"
|
|---|
| 24 | ("Snakes on a Plane" . 3.5)
|
|---|
| 25 | ("Just My Luck" . 3.0)
|
|---|
| 26 | ("The Night Listener" . 4.5)
|
|---|
| 27 | ("Superman Returns" . 4.0)
|
|---|
| 28 | ("You, Me and Dupree" . 2.5))
|
|---|
| 29 | ("Mick LaSalle"
|
|---|
| 30 | ("Lady in the Water" . 3.0)
|
|---|
| 31 | ("Snakes on a Plane" . 4.0)
|
|---|
| 32 | ("Just My Luck" . 2.0)
|
|---|
| 33 | ("Superman Returns" . 3.0)
|
|---|
| 34 | ("The Night Listener" . 3.0)
|
|---|
| 35 | ("You, Me and Dupree" . 2.0))
|
|---|
| 36 | ("Jack Matthews"
|
|---|
| 37 | ("Lady in the Water" . 3.0)
|
|---|
| 38 | ("Snakes on a Plane" . 4.0)
|
|---|
| 39 | ("The Night Listener" . 3.0)
|
|---|
| 40 | ("Superman Returns" . 5.0)
|
|---|
| 41 | ("You, Me and Dupree" . 3.5))
|
|---|
| 42 | ("Toby"
|
|---|
| 43 | ("Snakes on a Plane" . 4.5)
|
|---|
| 44 | ("You, Me and Dupree" . 1.0)
|
|---|
| 45 | ("Superman Returns" . 4.0))))
|
|---|
| 46 |
|
|---|
| 47 | ;
|
|---|
| 48 | (defun $ (lst &rest items)
|
|---|
| 49 | (if items
|
|---|
| 50 | (apply '$ (assoc (car items) lst :test #'equal) (cdr items))
|
|---|
| 51 | (cdr lst)))
|
|---|
| 52 |
|
|---|
| 53 | ;($ *critics* "Lisa Rose")
|
|---|
| 54 | ;($ *critics* "Lisa Rose" "Lady in the Water")
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 | ;;; p10 2.3.1 ���[�N���b�h�����ɂ��X�R�A
|
|---|
| 58 |
|
|---|
| 59 | (defun sim-distance (prefs person1 person2)
|
|---|
| 60 | ;; ��Ƃ������Ă����C�e���̃��X�g�� (let ((si (intersection (mapcar #'car ($ prefs person1))
|
|---|
| 61 | (mapcar #'car ($ prefs person2))
|
|---|
| 62 | :test #'equal)))
|
|---|
| 63 | ;; ���҂Ƃ��]�����Ă����̂��������� 0 ���
|
|---|
| 64 | (if (not si)
|
|---|
| 65 | 0
|
|---|
| 66 | ;; ���ׂĂ̍��̕��������킹�� (let ((sum-of-squares
|
|---|
| 67 | (reduce #'+ (mapcar #'(lambda (item)
|
|---|
| 68 | (expt (- ($ prefs person1 item)
|
|---|
| 69 | ($ prefs person2 item))
|
|---|
| 70 | 2))
|
|---|
| 71 | si))))
|
|---|
| 72 | (/ 1 (1+ sum-of-squares))))))
|
|---|
| 73 |
|
|---|
| 74 | ;(sim-distance *critics* "Lisa Rose" "Gene Seymour")
|
|---|
| 75 |
|
|---|