- ;;; UMLS-Parse
-;;; Lisp Routines for parsing UMLS files
-;;; and inserting into SQL databases
-;;;
-;;; Copyright (c) 2001 Kevin M. Rosenberg, M.D.
-;;; $Id: parse-2002.lisp,v 1.1 2002/10/05 20:17:14 kevin Exp $
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: umlisp -*-
+;;;; *************************************************************************
+;;;; FILE IDENTIFICATION
+;;;;
+;;;; Name: parse-2002.lisp
+;;;; Purpose: Parsing and SQL insertion routines for UMLisp which may
+;;;; change from year to year
+;;;; Programmer: Kevin M. Rosenberg
+;;;; Date Started: Apr 2000
+;;;;
+;;;; $Id: parse-2002.lisp,v 1.4 2002/10/14 09:25:20 kevin Exp $
+;;;;
+;;;; This file, part of UMLisp, is
+;;;; Copyright (c) 2000-2002 by Kevin M. Rosenberg, M.D.
+;;;;
+;;;; UMLisp users are granted the rights to distribute and use this software
+;;;; as governed by the terms of the GNU General Public License.
+;;;; *************************************************************************
(in-package :umlisp)
+(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)
(setq *parse-hash-init?* t))
(with-buffered-umls-file (line "MRCON")
(let ((cui (parse-ui (aref line 0)))
- (lui (parse-ui (nth 3 line)))
- (sui (parse-ui (nth 5 line)))
- (lrl (parse-integer (nth 7 line))))
+ (lui (parse-ui (aref line 3)))
+ (sui (parse-ui (aref line 5)))
+ (lrl (parse-integer (aref line 7))))
(unless (gethash cui pfstr-hash) ;; if haven't stored pfstr for cui
(if (and (string-equal (aref line 1) "ENG") ; LAT
(string-equal (aref line 2) "P") ; ts
(set-lrl-hash lui lrl lui-lrl-hash)
(set-lrl-hash (make-cuisui cui sui) lrl cuisui-lrl-hash)))
(with-buffered-umls-file (line "MRSO")
- (let ((sab (aref 3 line)))
+ (let ((sab (aref line 3)))
(unless (gethash sab sab-srl-hash) ;; if haven't stored
- (setf (gethash sab sab-srl-hash) (aref 6 line))))))
+ (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?*))
(gethash cuisui cuisui-lrl-hash))
(defun sab-srl (sab)
- (gu:aif (gethash sab sab-srl-hash) gu::it 0))
+ (kmrcl:aif (gethash sab sab-srl-hash) kmrcl::it 0))
)) ;; closure
(defun set-lrl-hash (key lrl hash)
;;; sql-l - Big integer (64-bit)
;;; sql-f - Floating point
-(defconstant +col-datatypes+
+(defparameter +col-datatypes+
'(("AV" sql-f) ("BTS" sql-i) ("CLS" sql-i) ("COF" sql-i) ("CUI1" sql-u)
("CUI2" sql-u) ("CUI" sql-u) ("CXN" sql-s) ("FR" sql-i) ("LRL" sql-s)
("LUI" sql-u) ("MAX" sql-s) ("MIN" sql-s) ("RANK" sql-s) ("REF" sql-s)
("UI" sql-u) ("UI2" sql-u) ("UI3" sql-u))
"SQL data types for each non-string column")
-(defconstant +custom-tables+
+(defparameter +custom-tables+
nil
#+ignore
'(("MRCONSO" "SELECT m.CUI, m.LAT, m.TS, m.LUI, m.STT, m.SUI, m.STR, m.LRL, s.SAB, s.TTY, s.SCD, s.SRL FROM MRCON m, MRSO s WHERE m.CUI=s.CUI AND m.LUI=s.LUI AND m.SUI=s.SUI")
("MRCONFULL" "SELECT m.CUI, m.LAT, m.TS, m.LUI, m.STT, m.SUI, m.STR, m.LRL, s.SAB, s.TTY, s.SCD, s.SRL, t.TUI FROM MRCON m, MRSO s, MRSTY t WHERE m.CUI=s.CUI AND m.LUI=s.LUI AND m.SUI=s.SUI AND m.CUI=t.CUI AND s.CUI=t.CUI"))
"Custom tables to create")
-(defconstant +custom-cols+
+(defparameter +custom-cols+
'(("MRCON" "KPFSTR" "TEXT" 1024
(lambda (x) (pfstr-hash (parse-ui (nth 0 x)))))
("MRCON" "KCUISUI" "BIGINT" 0
("MRCOC" "KLRL" "INTEGER" 0
(lambda (x) (format nil "~d"
(max (cui-lrl (parse-ui (nth 0 x)))
- (gu:aif (cui-lrl (parse-ui (nth 1 x))) gu::it 0)))))
+ (kmrcl:aif (cui-lrl (parse-ui (nth 1 x))) kmrcl::it 0)))))
("MRSAT" "KSRL" "INTEGER" 0
(lambda (x) (format nil "~d" (sab-srl (nth 5 x)))))
("MRREL" "KSRL" "INTEGER" 0
(lambda (x) (format nil "~d" (make-cuisui (parse-ui (nth 2 x)) (parse-ui (nth 4 x)))))))
"Custom columns to create.(filename, col, sqltype, value-func).")
-(defconstant +index-cols+
+(defparameter +index-cols+
'(("CUI" "MRATX") ("CUI1" "MRCOC") ("CUI" "MRCON") ("LUI" "MRCON")
("LRL" "MRCON")
("SUI" "MRCON") ("CUI" "MRCXT") ("CUI" "MRDEF") ("CUI" "MRLO")
"Columns in files to index")
-(defconstant +custom-index-cols+
+(defparameter +custom-index-cols+
nil
#+ignore
'(("CUI" "MRCONFULL") ("SAB" "MRCONFULL") ("TUI" "MRCONFULL"))