r11209: fix test
[umlisp.git] / parse-rrf.lisp
index 2e744ad9764cc5979c2234977002f5729aba108d..4076dc7c47635615d12b3813d2beb2030922f814 100644 (file)
@@ -2,7 +2,7 @@
 ;;;; *************************************************************************
 ;;;; FILE IDENTIFICATION
 ;;;;
-;;;; Name:     parse-2002.lisp
+;;;; Name:     parse-rrf.lisp
 ;;;; Purpose:  Parsing and SQL insertion routines for UMLisp which may
 ;;;;           change from year to year
 ;;;; Author:   Kevin M. Rosenberg
           (clrhash cuisui-lrl-hash)
           (clrhash sab-srl-hash))
       (setf
-         pfstr-hash (make-hash-table :size 800000)
-         cui-lrl-hash (make-hash-table :size 800000)
-         lui-lrl-hash (make-hash-table :size 1500000)
-         sui-lrl-hash (make-hash-table :size 1500000)
-         cuisui-lrl-hash (make-hash-table :size 1800000)
+         pfstr-hash (make-hash-table :size 1300000)
+         cui-lrl-hash (make-hash-table :size 1300000)
+         lui-lrl-hash (make-hash-table :size 4600000)
+         sui-lrl-hash (make-hash-table :size 5100000)
+         cuisui-lrl-hash (make-hash-table :size 2000000)
          sab-srl-hash (make-hash-table :size 100 :test 'equal))))
 
   (defun ensure-preparse (&optional (force-read nil))
     (when (and *preparse-hash-init?* (not force-read))
       (return-from ensure-preparse 'already-done))
     (make-preparse-hash-table)
-    (with-umls-file (line "MRCONSO.RRF")
-      (let ((cui (parse-ui (nth 0 line)))
-            (lui (parse-ui (nth 3 line)))
-            (sui (parse-ui (nth 5 line)))
-            (sab (nth 11 line))
-            (srl (parse-integer (nth 15 line))))
-        (unless (gethash cui pfstr-hash)  ;; if haven't stored pfstr for cui
-            (if (and (string-equal (nth 1 line) "ENG") ; LAT
-                     (string-equal (nth 2 line) "P") ; ts
-                     (string-equal (nth 4 line) "PF")) ; stt
+    (let ((counter 0))
+      (declare (fixnum counter))
+      (with-umls-file (line "MRCONSO.RRF")
+        (let ((cui (parse-ui (nth 0 line)))
+              (lui (parse-ui (nth 3 line)))
+              (sui (parse-ui (nth 5 line)))
+              (sab (nth 11 line))
+              (srl (parse-integer (nth 15 line))))
+          #+sbcl
+          (when (= 0 (mod (incf counter) 100000)) (sb-ext:gc :full t))
+
+          ;; pfstr deprecated by KPKENG field in MRCONSO
+          #+nil
+          (unless (gethash cui pfstr-hash)  ;; if haven't stored pfstr for cui
+            (when (and (string-equal (nth 1 line) "ENG") ; LAT
+                       (string-equal (nth 2 line) "P") ; ts
+                       (string-equal (nth 4 line) "PF")) ; stt
              (setf (gethash cui pfstr-hash) (nth 14 line))))
-        (set-lrl-hash cui srl cui-lrl-hash)
-        (set-lrl-hash lui srl lui-lrl-hash)
-        (set-lrl-hash sui srl sui-lrl-hash)
-        (set-lrl-hash (make-cuisui cui sui) srl cuisui-lrl-hash)
-        (multiple-value-bind (val found) (gethash sab sab-srl-hash)
-          (declare (ignore val))
-          (unless found
-            (setf (gethash sab sab-srl-hash) srl)))))
+          (set-lrl-hash cui srl cui-lrl-hash)
+          (set-lrl-hash lui srl lui-lrl-hash)
+          (set-lrl-hash sui srl sui-lrl-hash)
+          (set-lrl-hash (make-cuisui cui sui) srl cuisui-lrl-hash)
+          (multiple-value-bind (val found) (gethash sab sab-srl-hash)
+            (declare (ignore val))
+            (unless found
+              (setf (gethash sab sab-srl-hash) srl))))))
     (setq *preparse-hash-init?* t)
     t)
 
-  (defun pfstr-hash (cui) (gethash cui pfstr-hash))
+  #+nil (defun pfstr-hash (cui) (gethash cui pfstr-hash))
   (defun cui-lrl (cui)    (gethash cui cui-lrl-hash))
   (defun lui-lrl (lui)    (gethash lui lui-lrl-hash))
   (defun sui-lrl (sui)    (gethash sui sui-lrl-hash))
       ("SUI" "MRCONSO") ("SAUI" "MRCONSO") ("CODE" "MRCONSO")
       ("SCUI" "MRCONSO")
       ("CUI" "MRDEF")
-      ("CUI1" "MRREL") ("CUI2" "MRREL")
-      ("RUI" "MRREL") ("AUI" "MRREL") ("AUI2" "MRREL")
+      ("CUI1" "MRREL") ("CUI2" "MRREL") ("SAB" "MRREL")
+      ("RUI" "MRREL") ("AUI1" "MRREL") ("AUI2" "MRREL")
       ("CUI" "MRSAT") ("LUI" "MRSAT") ("SUI" "MRSAT")
       ("METAUI" "MRSAT") ("ATN" "MRSAT")
       ("CUI" "MRSTY")  ("TUI" "MRSTY") ("CUI" "MRXNS_ENG")
-      ("AUI" "MRHIER") ("PTR" "MRHIER" 255) ("CUI" "MRHIER") ("CXN" "MRHIER") ("RELA" "MRHIER") ("PAUI" "MRHIER")
+      ("AUI" "MRHIER") ("CUI" "MRHIER") ("CXN" "MRHIER") ("RELA" "MRHIER") ("PAUI" "MRHIER")
       ("SAB" "MRHIER")
       #+ignore ("NSTR" "MRXNS_ENG" 10)
       ("CUI" "MRXNW_ENG") ("NWD" "MRXNW_ENG") ("WD" "MRXW_ENG")