r4876: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Thu, 8 May 2003 04:36:12 +0000 (04:36 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Thu, 8 May 2003 04:36:12 +0000 (04:36 +0000)
create-sql.lisp
parse-2002.lisp
parse-common.lisp
tests/package.lisp
tests/parse.lisp

index a6f8ad390f4f0aecfa9ae10fbcf186923e203c3e..80d842abe55a6f9944903c925e9bbd1e78123f8f 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Author:        Kevin M. Rosenberg
 ;;;; Date Started:  Apr 2000
 ;;;;
-;;;; $Id: create-sql.lisp,v 1.2 2003/05/07 22:53:36 kevin Exp $
+;;;; $Id: create-sql.lisp,v 1.3 2003/05/08 04:36:12 kevin Exp $
 ;;;;
 ;;;; This file, part of UMLisp, is
 ;;;;    Copyright (c) 2000-2002 by Kevin M. Rosenberg, M.D.
 
 (defun create-umls-db-by-insert ()
   "SQL Databases: initializes entire database via SQL insert commands"
-  (ensure-init-umls)
-  (init-hash-table)
+  (ensure-ucols+ufiles)
+  (ensure-preparse)
   (with-sql-connection (conn)
     (sql-drop-tables conn)
     (sql-create-tables conn)
                       (copy-cmd #'mysql-copy-cmd))
   "SQL Databases: initializes entire database via SQL copy commands. 
 This is much faster that using create-umls-db-insert."
-  (ensure-init-umls)
-  (init-hash-table)
+  (ensure-ucols+ufiles)
+  (ensure-preparse)
   (translate-all-files extension)
   (with-sql-connection (conn)
     (sql-drop-tables conn)
@@ -276,7 +276,7 @@ This is much faster that using create-umls-db-insert."
            (nreverse avoidable) (nreverse unavoidable))))
 
 (defun display-waste ()
-  (ensure-init-umls)
+  (ensure-ucols+ufiles)
   (multiple-value-bind (tw ta tu al ul) (umls-fixed-size-waste)
     (format t "Total waste: ~d~%" tw)
     (format t "Total avoidable: ~d~%" ta)
@@ -292,7 +292,7 @@ This is much faster that using create-umls-db-insert."
 (defun max-umls-field ()
   "Return length of longest field"
   (declare (optimize (speed 3) (space 0)))
-  (ensure-init-umls)
+  (ensure-ucols+ufiles)
   (let ((max 0))
     (declare (fixnum max))
     (dolist (ucol *umls-cols*)
@@ -303,7 +303,7 @@ This is much faster that using create-umls-db-insert."
 (defun max-umls-row ()
   "Return length of longest row"
   (declare (optimize (speed 3) (space 0)))
-  (ensure-init-umls)
+  (ensure-ucols+ufiles)
   (let ((rowsizes '()))
     (dolist (file *umls-files*)
       (let ((row 0))
index 9e70e3c891c1a56c15bb1eeedbd4cd48c188a446..7dbd52270c2937034e2b79d7061d336fcff144ec 100644 (file)
@@ -8,7 +8,7 @@
 ;;;; Author:        Kevin M. Rosenberg
 ;;;; Date Started:  Apr 2000
 ;;;;
-;;;; $Id: parse-2002.lisp,v 1.11 2003/05/08 02:59:21 kevin Exp $
+;;;; $Id: parse-2002.lisp,v 1.12 2003/05/08 04:36:12 kevin Exp $
 ;;;;
 ;;;; This file, part of UMLisp, is
 ;;;;    Copyright (c) 2000-2002 by Kevin M. Rosenberg, M.D.
@@ -23,7 +23,7 @@
   (declaim (optimize (speed 3) (safety 1) (compilation-speed 0) (debug 3))))
 
 ;;; Pre-read data for custom fields into hash tables
-(defvar *parse-hash-init?* nil)
+(defvar *preparse-hash-init?* nil)
 
 (eval-when (:compile-toplevel :load-toplevel :execute)
 (let ((pfstr-hash nil)      ;;; Preferred concept strings by CUI
@@ -32,7 +32,7 @@
       (cuisui-lrl-hash nil) ;;; LRL by CUISUI
       (sab-srl-hash nil))   ;;; SRL by SAB
   
-  (defun make-parse-hash-table ()
+  (defun make-preparse-hash-table ()
     (if pfstr-hash
        (progn
          (clrhash pfstr-hash)
          cuisui-lrl-hash (make-hash-table :size 1800000)
          sab-srl-hash (make-hash-table :size 100 :test 'equal))))
     
-  (defun binit-hash-table (&optional (force-read nil))
-    (when (or force-read (not *parse-hash-init?*))
-      (make-parse-hash-table)
-      (setq *parse-hash-init?* t))
+  (defun buffered-ensure-preparse (&optional (force-read nil))
+    (when (or force-read (not *preparse-hash-init?*))
+      (make-preparse-hash-table)
+      (setq *preparse-hash-init?* t))
     (with-buffered-umls-file (line "MRCON")
       (let ((cui (parse-ui (aref line 0)))
            (lui (parse-ui (aref line 3)))
        (unless (gethash sab sab-srl-hash)  ;; if haven't stored
          (setf (gethash sab sab-srl-hash) (aref line 6))))))
   
-  (defun init-hash-table (&optional (force-read nil))
-    (when (or force-read (not *parse-hash-init?*))
-      (make-parse-hash-table)
-      (setq *parse-hash-init?* t))
+  (defun ensure-preparse (&optional (force-read nil))
+    (when (or force-read (not *preparse-hash-init?*))
+      (make-preparse-hash-table)
+      (setq *preparse-hash-init?* t))
     (with-umls-file (line "MRCON")
       (let ((cui (parse-ui (nth 0 line)))
            (lui (parse-ui (nth 3 line)))
     (gethash cuisui cuisui-lrl-hash))
   
   (defun sab-srl (sab)
-    (kmrcl:aif (gethash sab sab-srl-hash) kmrcl::it 0))
+    (aif (gethash sab sab-srl-hash) it 0))
 )) ;; closure
 
 (defun set-lrl-hash (key lrl hash)
index 3141b73c54d0dd2eb94fd15e0b6e2c8d498f7f46..bca8940c9232bed5688c014aa1945af96c4cf9c1 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Author:        Kevin M. Rosenberg
 ;;;; Date Started:  Apr 2000
 ;;;;
-;;;; $Id: parse-common.lisp,v 1.12 2003/05/08 01:28:30 kevin Exp $
+;;;; $Id: parse-common.lisp,v 1.13 2003/05/08 04:36:12 kevin Exp $
 ;;;;
 ;;;; This file, part of UMLisp, is
 ;;;;    Copyright (c) 2000-2002 by Kevin M. Rosenberg, M.D.
@@ -21,7 +21,7 @@
 (eval-when (:compile-toplevel)
   (declaim (optimize (speed 3) (safety 1) (compilation-speed 0) (debug 3))))
 
-(defun ensure-init-umls (&optional (alwaysclear nil))
+(defun ensure-ucols+ufiles (&optional (alwaysclear nil))
 "Initialize all UMLS file and column structures if not already initialized"
   (when (or alwaysclear (null *umls-files*))
     (gen-ucols)
index 166266c3832698cf541212862f82c5dd19664afc..d8d9b46bcec02b1938c468deb18ac4de2d350733 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Author:        Kevin M. Rosenberg
 ;;;; Date Started:  May 2003
 ;;;;
-;;;; $Id: package.lisp,v 1.1 2003/05/07 23:06:44 kevin Exp $
+;;;; $Id: package.lisp,v 1.2 2003/05/08 04:36:12 kevin Exp $
 ;;;;
 ;;;; This file, part of UMLisp, is
 ;;;;    Copyright (c) 2000-2002 by Kevin M. Rosenberg, M.D.
@@ -16,6 +16,8 @@
 ;;;; as governed by the terms of the GNU General Public License.
 ;;;; *************************************************************************
 
+(in-package #:cl-user)
+
 (defpackage #:umlisp-tests
   (:use #:umlisp #:cl #:rtest #:kmrcl))
 
index 71a479b1a08d244185667ddaa2a933d57a35425a..83282228de069e6dc07e6909024b65e85e7c6004 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Author:        Kevin M. Rosenberg
 ;;;; Date Started:  May 2003
 ;;;;
-;;;; $Id: parse.lisp,v 1.2 2003/05/08 01:28:30 kevin Exp $
+;;;; $Id: parse.lisp,v 1.3 2003/05/08 04:36:12 kevin Exp $
 ;;;;
 ;;;; This file, part of UMLisp, is
 ;;;;    Copyright (c) 2000-2002 by Kevin M. Rosenberg, M.D.
 
 #+umls-files
 (progn
-  (umlisp::ensure-init-umls)
+  (umlisp::ensure-ucols+ufiles)
   (deftest uparse.1 (length *umls-files*) 52)
   (deftest uparse.2 (length *umls-cols*) 327)
-  
+  (deftest uparse.3
+      (sort (mapcar #'u::col (umlisp::ucols (umlisp::find-ufile "MRCON")))
+           #'string<)
+    ("CUI" "KCUILRL" "KCUILUI" "KCUISUI" "KLUILRL" "KPFSTR" "LAT" "LRL" "LUI" "STR"
+               "STT" "SUI" "TS"))
+  (deftest uparse.4
+      (sort (umlisp::fields (umlisp::find-ufile "MRCON"))
+           #'string<)
+    ("CUI" "KCUILRL" "KCUILUI" "KCUISUI" "KLUILRL" "KPFSTR" "LAT" "LRL" "LUI" "STR"
+          "STT" "SUI" "TS"))
+  (deftest uparse.5
+      (sort
+       (umlisp::custom-colnames-for-filename "MRCON")
+       #'string<)
+    ("KCUILRL" "KCUILUI" "KCUISUI" "KLUILRL" "KPFSTR"))
+  (deftest uparse.6
+      (compiled-function-p
+       (umlisp::custom-value-fun
+       (umlisp::find-ucol "KCUISUI" "MRCON")))
+    t)
   ) ;; umls-files
 
 #+umls-files