-(defun score-multiword-match (s1 s2)
- "Score a match between two strings with s1 being reference string"
- (let* ((word-list-1 (delimited-string-to-list s1 #\space))
- (word-list-2 (delimited-string-to-list s2 #\space))
- (n1 (length word-list-1))
- (n2 (length word-list-2))
- (unmatched n1)
- (score 0)
- (nlong 0)
- (nshort 0)
- short-list long-list)
- (declare (fixnum n1 n2 nshort nlong score unmatched))
- (if (> n1 n2)
- (progn
- (setq nlong n1)
- (setq nshort n2)
- (setq long-list word-list-1)
- (setq short-list word-list-2))
- (progn
- (setq nlong n2)
- (setq nshort n1)
- (setq long-list word-list-2)
- (setq short-list word-list-1)))
- (decf score (- nlong nshort)) ;; reduce score for extra words
- (dotimes (iword nshort)
- (declare (fixnum iword))
- (kmrcl:aif (position (nth iword short-list) long-list :test #'string-equal)
- (progn
- (incf score (- 10 (abs (- kmrcl::it iword))))
- (decf unmatched))))
- (decf score (* 2 unmatched))
- score))
-