From 45453f00199223924481c8d6d614972a327a250f Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Thu, 8 May 2003 04:36:12 +0000 Subject: [PATCH] r4876: *** empty log message *** --- create-sql.lisp | 16 ++++++++-------- parse-2002.lisp | 24 ++++++++++++------------ parse-common.lisp | 4 ++-- tests/package.lisp | 4 +++- tests/parse.lisp | 25 ++++++++++++++++++++++--- 5 files changed, 47 insertions(+), 26 deletions(-) diff --git a/create-sql.lisp b/create-sql.lisp index a6f8ad3..80d842a 100644 --- a/create-sql.lisp +++ b/create-sql.lisp @@ -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. @@ -161,8 +161,8 @@ (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) @@ -176,8 +176,8 @@ (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)) diff --git a/parse-2002.lisp b/parse-2002.lisp index 9e70e3c..7dbd522 100644 --- a/parse-2002.lisp +++ b/parse-2002.lisp @@ -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) @@ -47,10 +47,10 @@ 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))) @@ -69,10 +69,10 @@ (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))) @@ -106,7 +106,7 @@ (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) diff --git a/parse-common.lisp b/parse-common.lisp index 3141b73..bca8940 100644 --- a/parse-common.lisp +++ b/parse-common.lisp @@ -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) diff --git a/tests/package.lisp b/tests/package.lisp index 166266c..d8d9b46 100644 --- a/tests/package.lisp +++ b/tests/package.lisp @@ -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)) diff --git a/tests/parse.lisp b/tests/parse.lisp index 71a479b..8328222 100644 --- a/tests/parse.lisp +++ b/tests/parse.lisp @@ -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. @@ -27,10 +27,29 @@ #+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 -- 2.34.1