;;;; 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)
(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)
(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*)
(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))
;;;; 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.
(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
(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)
;;;; 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.
(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)
;;;; 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.
;;;; as governed by the terms of the GNU General Public License.
;;;; *************************************************************************
+(in-package #:cl-user)
+
(defpackage #:umlisp-tests
(:use #:umlisp #:cl #:rtest #:kmrcl))
;;;; 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