X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=parse-rrf.lisp;h=9a1c4fe78a3df32d67ed917e05578b7a825cfb5a;hb=135cbbc7ad7773eef7e205b7f82d19ea17c346e4;hp=e8e919de245a0e34da419ac546bf35b7072cfc9c;hpb=1156ea284d3010afd2e113fc4ddb325290b8a7a4;p=umlisp.git diff --git a/parse-rrf.lisp b/parse-rrf.lisp index e8e919d..9a1c4fe 100644 --- a/parse-rrf.lisp +++ b/parse-rrf.lisp @@ -187,14 +187,25 @@ used in the United States. We create a new scale (SRLUS) where SRL to SRLUS mapp '(("KCON" "SELECT CUI,STR FROM MRCONSO WHERE STT='PF' AND TS='P' AND ISPREF='Y' AND LAT='ENG'")) "Custom tables to create") +(defvar *vff-position-hash* (make-hash-table :size 100 :test 'eq)) + + (defmacro vff (filename fieldname record) (let ((pos (gensym "POS-")) + (found (gensym "FOUND-")) (key (kmrcl:ensure-keyword (concatenate 'string filename "^" fieldname)))) - `(let ((,pos (position-field-file ,filename ,fieldname ,key))) - (unless ,pos - (error "Did not find fieldname ~A in filename ~A." ,fieldname ,filename)) - (locally (declare (type (integer 0 100000) ,pos)) - (nth ,pos ,record))))) + `(locally (declare (optimize (speed 3) (safety 0))) + (multiple-value-bind (,pos ,found) (gethash ,key *vff-position-hash*) + (declare (ignore ,found)) + (if ,pos + (locally (declare (type (integer 0 100000) ,pos)) + (nth ,pos ,record)) + (let ((,pos (position-field-file ,filename ,fieldname))) + (unless ,pos + (error "Did not find fieldname ~A in filename ~A." ,fieldname ,filename)) + (locally (declare (type (integer 0 100000) ,pos)) + (setf (gethash ,key *vff-position-hash*) ,pos) + (nth ,pos ,record)))))))) (defparameter +custom-cols+ '(#+nil ("MRCONSO.RRF" "KPFSTR" "TEXT"