r5354: *** empty log message ***
[umlisp.git] / class-support.lisp
index 84a4790d74672f2e9e55c81c1a31fd471994ade0..3245a1f96154a680b36514786ac689cb7daee95b 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Author:       Kevin M. Rosenberg
 ;;;; Date Started: Apr 2000
 ;;;;
-;;;; $Id: class-support.lisp,v 1.13 2003/06/15 07:48:30 kevin Exp $
+;;;; $Id: class-support.lisp,v 1.18 2003/07/21 00:53:27 kevin Exp $
 ;;;;
 ;;;; This file, part of UMLisp, is
 ;;;;    Copyright (c) 2000-2003 by Kevin M. Rosenberg, M.D.
       (or (not is-term) is-english)))
 
 (defun print-umlsclass (obj &key (stream *standard-output*)
-                       (category :compact-text)
-                       (file-wrapper t) (english-only t) (subobjects nil)
+                       (vid :compact-text)
+                       (file-wrapper nil) (english-only t) (subobjects nil)
                        (refvars nil) (link-printer nil))
-  (view obj :stream stream :category category :subobjects subobjects
+  (view obj :stream stream :vid vid :subobjects subobjects
        :file-wrapper file-wrapper
        :filter (if english-only nil #'english-term-filter)
        :link-printer link-printer
 
 (defmacro define-lookup-display (newfuncname lookup-func)
   "Defines functions for looking up and displaying objects"
-  `(defun ,newfuncname  (keyval &key (stream *standard-output*) (category :compact-text)
+  `(defun ,newfuncname  (keyval &key (stream *standard-output*) (vid :compact-text)
                         (file-wrapper t) (english-only nil) (subobjects nil))
      (let ((obj (funcall ,lookup-func keyval)))
-       (print-umlsclass obj :stream stream :category category
+       (print-umlsclass obj :stream stream :vid vid
                        :file-wrapper file-wrapper :english-only english-only
                        :subobjects subobjects)
        obj)))
   "Return the string for a ulo object"
   (find-string-sui (sui lo)))
 
-(defun uterm-pfstr (uterm)
+(defmethod pfstr ((uterm uterm))
   "Return the preferred string for a uterm"
   (dolist (ustr (s#str uterm))
     (when (string= "PF" (stt ustr))
-      (return-from uterm-pfstr (str ustr)))))
+      (return-from pfstr (str ustr)))))
+
+(defmethod pfstr ((ustr ustr))
+  "Return the preferred string for a ustr, which is the string itself"
+  (str ustr))
 
 (defun remove-non-english-terms (uterms)
   (remove-if-not #'english-term-p uterms))
 
-
-#+(or scl cmu)
+(defun remove-english-terms (uterms)
+  (remove-if #'english-term-p uterms))
+
+
+(defvar +relationship-abbreviations+
+  '(("RB" "Broader" "has a broader relationship")
+    ("RN" "Narrower" "has a narrower relationship")
+    ("RO" "Other related" "has relationship other than synonymous, narrower, or broader")
+    ("RL" "Like" "the two concepts are similar or 'alike'.  In the current edition of the Metathesaurus, most relationships with this attribute are mappings provided by a source")
+    ("RQ" "Unspecified" "unspecified source asserted relatedness, possibly synonymous")
+    ("SY" "Source Synonymy" "source asserted synonymy")
+    ("PAR" "Parent" "has parent relationship in a Metathesaurus source vocabulary")
+    ("CHD" "Child" "has child relationship in a Metathesaurus source vocabulary")
+    ("SIB" "Sibling" "has sibling relationship in a Metathesaurus source vocabulary")
+    ("AQ" "Allowed" "is an allowed qualifier for a concept in a Metathesaurus source vocabulary")
+    ("QB" "Qualified" "can be qualified by a concept in a Metathesaurus source vocabulary")))
+
+(defvar *rel-info-table* (make-hash-table :size 30 :test 'equal))
+(defvar *is-rel-table-init* nil)
+(unless *is-rel-table-init*
+  (dolist (relinfo +relationship-abbreviations+)
+    (setf (gethash (string-downcase (car relinfo)) *rel-info-table*)
+      (cdr relinfo)))
+  (setq *is-rel-table-init* t))
+
+(defun rel-abbr-info (rel)
+  (nth-value 0 (gethash (string-downcase rel) *rel-info-table*)))
+
+
+#+(or scl)
 (dolist (c '(urank udef usat uso ucxt ustr ulo uterm usty urel ucoc uatx ucon uxw uxnw uxns lexterm labr lagr lcmp lmod lnom lprn lprp lspl ltrm ltyp lwd sdef sstr sstre1 sstre2 usrl))
     #+cmu
     (let ((cl (pcl:find-class c)))