(in-package :tsdb) (defun iaa (left right &key (log t) (test :na) (condition *statistics-select-condition*)) (format log "‘~a’ vs. ‘~a’:~%" left right) (loop with left = (analyze left :condition condition :thorough '(:mrs)) with right = (analyze right :condition condition :thorough '(:mrs)) with gt = 0 with gg = 0 with gc = 0 with n = 0 for foo in left for bar in right for id = (get-field :i-id foo) for lmrs = (get-field :mrs (first (get-field :results foo))) for rmrs = (get-field :mrs (first (get-field :results bar))) unless (= id (get-field :i-id bar)) do (error "iaa(): mis-alignment (~a vs. ~a)" id (get-field :i-id bar)) unless (and (mrs::psoa-p lmrs) (mrs::psoa-p rmrs)) do (format log "iaa(): invalid MRSs for item #~a" id) unless (not (and (mrs::psoa-p lmrs) (mrs::psoa-p rmrs))) do (let* ((edm (mrs::edm lmrs rmrs)) (test (string test)) (it (+ (if (find #\N test) (get-field :tn edm) 0) (if (find #\A test) (get-field :ta edm) 0) (if (find #\P test) (get-field :tp edm) 0))) (ig (+ (if (find #\N test) (get-field :gn edm) 0) (if (find #\A test) (get-field :ga edm) 0) (if (find #\P test) (get-field :gp edm) 0))) (ic (+ (if (find #\N test) (get-field :cn edm) 0) (if (find #\A test) (get-field :ca edm) 0) (if (find #\P test) (get-field :cp edm) 0)))) (format log "[~a] ~a test; ~a gold; ~a correct: ~ P = ~,2f; R = ~,2f; F1 = ~,2f;~%" id it ig ic (/ ic it) (/ ic ig) (f-one it ig ic)) (incf gt it) (incf gg ig) (incf gc ic) (incf n)) finally (format log "[~a item~p] ~a test; ~a gold; ~a correct: ~ P = ~,2f; R = ~,2f; F1 = ~,2f.~%" n n gt gg gc (/ gc gt) (/ gc gg) (f-one gt gg gc)) (return (values n gt gg gc)))) (tsdb :home (namestring (make-pathname :directory (append (pathname-directory *load-truename*) '("tsdb"))))) (iaa "a" "b") (iaa "a" "c") (iaa "b" "c")