r3539: *** empty log message ***
[umlisp.git] / classes.lisp
1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: umlisp -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          classes.lisp
6 ;;;; Purpose:       Class defintions for UMLisp
7 ;;;; Programmer:    Kevin M. Rosenberg
8 ;;;; Date Started:  Apr 2000
9 ;;;;
10 ;;;; $Id: classes.lisp,v 1.19 2002/12/03 00:12:41 kevin Exp $
11 ;;;;
12 ;;;; This file, part of UMLisp, is
13 ;;;;    Copyright (c) 2000-2002 by Kevin M. Rosenberg, M.D.
14 ;;;;
15 ;;;; UMLisp users are granted the rights to distribute and use this software
16 ;;;; as governed by the terms of the GNU General Public License.
17 ;;;; *************************************************************************
18
19 (in-package :umlisp)
20 (declaim (optimize (speed 3) (safety 1) (compilation-speed 0) (debug 3)))
21
22 (defclass umlsclass (hyperobject)
23   ()
24   (:metaclass hyperobject-class)
25   (:description "Parent class of all UMLS objects. It is based on the HYPEROBJECT-CLASS metaclass that provides object printing functions."))
26
27
28 (defclass usrl (umlsclass)
29   ((sab :type string :initarg :sab :reader sab)
30    (srl :type fixnum :initarg :srl :reader srl))
31   (:metaclass hyperobject-class)
32   (:default-initargs :sab nil :srl nil)
33   (:title "Source Restriction Level")
34   (:print-slots sab srl)
35   (:description "Custom Table: Source Restriction Level"))
36
37   
38 (defclass urank (umlsclass)
39   ((rank :type fixnum :initarg :rank :reader rank)
40    (sab :type string :initarg :sab :reader sab)
41    (tty :type string :initarg :tty :reader tty)
42    (supres :type string :initarg :supres :reader supres))
43   (:metaclass hyperobject-class)
44   (:default-initargs :rank nil :sab nil :tty nil :supres nil)
45   (:title "Rank")
46   (:print-slots rank sab tty supres))
47
48 (defclass udef (umlsclass)
49   ((def :type cdata :initarg :def :reader def)
50    (sab :type string :initarg :sab :reader sab :hyperlink find-usab-rsab))
51   (:metaclass hyperobject-class)
52   (:default-initargs :def nil :sab nil)
53   (:title "Definition")
54   (:print-slots sab def))
55
56 (defclass usat (umlsclass)
57   ((sab :type string :initarg :sab :reader sab :hyperlink find-usab-rsab)
58    (code :type string :initarg :code :reader code)
59    (atn :type string :initarg :atn :reader atn)
60    (atv :type cdata :initarg :atv :reader atv))
61   (:metaclass hyperobject-class)
62   (:default-initargs :sab nil :code nil :atn nil :atv nil)
63   (:title "Simple Attribute")
64   (:print-slots sab code atn atv))
65
66 (defclass usab (umlsclass)
67   ((vcui :type fixnum :initarg :vcui :reader vcui :print-formatter fmt-cui)
68    (rcui :type fixnum :initarg :rcui :reader rcui :print-formatter fmt-cui)
69    (vsab :type string :initarg :vsab :reader vsab)
70    (rsab :type string :initarg :rsab :reader rsab :hyperlink find-ucan-sab)
71    (son :type string :initarg :son :reader son)
72    (sf :type string :initarg :sf :reader sf)
73    (sver :type string :initarg :sver :reader sver)
74    (mstart :type string :initarg :mstart :reader mstart)
75    (mend :type string :initarg :mend :reader mend)
76    (imeta :type string :initarg :imeta :reader imeta)
77    (rmeta :type string :initarg :rmeta :reader rmeta)
78    (slc :type cdata :initarg :slc :reader slc)
79    (scc :type cdata :initarg :scc :reader scc)
80    (srl :type fixnum :initarg :srl :reader srl)
81    (tfr :type fixnum :initarg :tfr :reader tfr :print-formatter fmt-comma-integer)
82    (cfr :type fixnum :initarg :cfr :reader cfr :print-formatter fmt-comma-integer)
83    (cxty :type string :initarg :cxty :reader cxty)
84    (ttyl :type string :initarg :ttyl :reader ttyl)
85    (atnl :type string :initarg :atnl :reader atnl)
86    (lat :type string :initarg :lat :reader lat)
87    (cenc :type string :initarg :cenc :reader cenc)
88    (curver :type string :initarg :curver :reader curver)
89    (sabin :type string :initarg :sabin :reader sabin))
90   (:metaclass hyperobject-class)
91   (:default-initargs :vcui nil :rcui nil :vsab nil :rsab nil :son nil :sf nil
92                      :sver nil :mstart nil :mend nil :imeta nil :rmeta nil
93                      :slc nil :scc nil :srl nil :tfr nil :cfr nil :cxty nil
94                      :ttyl nil :atnl nil :lat nil :cenc nil :curver nil
95                      :sabin nil)
96   (:title "Source Abbreviation")
97   (:print-slots vcui rcui vsab rsab son sf sver mstart mend imeta
98                 rmeta slc scc srl tfr cfr cxty ttyl atnl lat cenc
99                 curver sabin))
100
101 (defclass uso (umlsclass)
102   ((sab :type string :initarg :sab :reader sab :hyperlink find-usab-rsab)
103    (code :type string :initarg :code :reader code)
104    (tty :type string :initarg :tty :reader tty :hyperlink find-btty-tty)
105    (srl :type fixnum :initarg :srl :reader srl))
106   (:metaclass hyperobject-class)
107   (:default-initargs :sab nil :code nil :tty nil :srl nil)
108   (:title "Source")
109   (:print-slots sab code tty srl))
110
111 (defclass ucxt (umlsclass)
112   ((sab :type string :initarg :sab :reader sab :hyperlink find-usab-rsab)
113    (code :type string :initarg :code :reader code)
114    (rnk :type fixnum :initarg :rnk :reader rnk)
115    (cxn :type fixnum :initarg :cxn :reader cxn)
116    (cxl :type string :initarg :cxl :reader cxl)
117    (cxs :type cdata :initarg :cxs :reader cxs)
118    (cui2 :type fixnum :initarg :cui2 :reader cui2 :hyperlink find-ucon-cui
119          :print-formatter fmt-cui)
120    (hcd :type string :initarg :hcd :reader hcd)
121    (rela :type string :initarg :rela :reader rela)
122    (xc :type string  :initarg :xc :reader xc))
123   (:metaclass hyperobject-class)
124   (:default-initargs :sab nil :code nil :rnk nil :cxn nil :cxl nil :cxs nil
125                      :cui2 nil :hcd nil :rela nil :xc nil)
126   (:title "Context")
127   (:print-slots sab code rnk cxn cxl hcd rela xc cui2 cxs))
128
129 (defclass ustr (umlsclass)
130   ((sui :type fixnum :initarg :sui :reader sui :print-formatter fmt-sui
131         :hyperlink find-ustr-sui)
132    (cui :type fixnum :initarg :cui :reader cui :print-formatter fmt-cui)
133    (lui :type fixnum :initarg :lui :reader lui :print-formatter fmt-lui
134         :hyperlink find-uterm-lui)
135    (cuisui :type integer :initarg :cuisui :reader cuisui )
136    (str :type cdata :initarg :str :reader str)
137    (lrl :type fixnum :initarg :lrl :reader lrl)
138    (stt :type string :initarg :stt :reader stt)
139    (s#sat :reader s#sat :subobject t)
140    (s#so :reader s#so :subobject t)
141    (s#cxt :reader s#cxt :subobject t))
142   (:metaclass hyperobject-class)
143   (:default-initargs 
144    :sui nil :cui nil :lui nil :cuisui nil :str nil :lrl nil :stt nil)
145   (:title "String")
146   (:print-slots sui stt lrl str))
147
148 (defclass ulo (umlsclass)
149   ((isn :type string :initarg :isn :reader isn)
150    (fr :type fixnum :initarg :fr :reader fr)
151    (un :type string :initarg :un :reader un)
152    (sui :type fixnum :initarg :sui :reader sui :print-formatter fmt-sui)
153    (sna :type string :initarg :sna :reader sna)
154    (soui :type string :initarg :soui :reader soui))
155   (:metaclass hyperobject-class)
156   (:default-initargs :isn nil :fr nil :un nil :sui nil :sna nil :soui nil)
157   (:title "Locator")
158   (:print-slots isn fr un sna soui sui))
159
160 (defclass uterm (umlsclass)
161   ((lui :type fixnum :initarg :lui :reader lui :hyperlink find-uterm-lui)
162    (cui :type fixnum :initarg :cui :reader cui)
163    (lat :type string :initarg :lat :reader lat)
164    (ts :type string  :initarg :ts :reader ts)
165    (lrl :type fixnum :initarg :lrl :reader lrl)
166    (s#str :reader s#str :subobject t)
167    (s#sat :reader s#sat :subobject t))
168   (:metaclass hyperobject-class)
169   (:default-initargs :lui nil :cui nil :lat nil :ts nil :lrl nil)
170   (:title "Term")
171   (:print-slots lui lat ts lrl))
172
173 (defclass usty (umlsclass)
174   ((tui :type fixnum :initarg :tui :reader tui :print-formatter fmt-tui
175         :hyperlink (find-ucon-tui ("subobjects" "no")))
176    (sty :type string :initarg :sty :reader sty))
177   (:metaclass hyperobject-class)
178   (:default-initargs :tui nil :sty nil)
179   (:title "Semantic Type")
180   (:print-slots tui sty))
181
182 (defclass urel (umlsclass)
183   ((rel :type string :initarg :rel :reader rel :hyperlink find-brel-rel)
184    (cui1 :type fixnum :initarg :cui1 :reader cui1 :print-formatter fmt-cui)
185    (cui2 :type fixnum :initarg :cui2 :reader cui2 :hyperlink find-ucon-sui
186          :print-formatter fmt-cui)
187    (pfstr2 :type cdata :initarg :pfstr2 :reader pfstr2)
188    (rela :type string :initarg :rela :reader rela)
189    (sab :type string :initarg :sab :reader sab :hyperlink find-usab-rsab)
190    (sl :type string  :initarg :sl :reader sl)
191    (mg :type string  :initarg :mg :reader mg))
192   (:metaclass hyperobject-class)
193   (:default-initargs 
194    :rel nil :cui1 nil :cui2 nil :pfstr2 nil :rela nil :sab nil :sl nil :mg nil)
195   (:title "Relationship")
196   (:print-slots rel rela sab sl mg cui2 pfstr2))
197         
198 (defclass ucoc (umlsclass)
199   ((cui1 :type fixnum :initarg :cui1 :reader cui1 :print-formatter fmt-cui)
200    (cui2 :type fixnum :initarg :cui2 :reader cui2 :print-formatter fmt-cui
201          :hyperlink find-ucon-cui)
202    (pfstr2 :type cdata :initarg :pfstr2 :reader pfstr2)
203    (soc :type string :initarg :soc :reader soc)
204    (cot :type string :initarg :cot :reader cot)
205    (cof :type fixnum :initarg :cof :reader cof)
206    (coa :type cdata :initarg :coa :reader coa))
207   (:metaclass hyperobject-class)
208   (:default-initargs 
209    :cui1 nil :cui2 nil :pfstr2 nil :soc nil :cot nil :cof nil :coa nil)
210   (:title "Co-occuring Concept")
211   (:print-slots soc cot cof coa cui2 pfstr2))
212
213         
214 (defclass uatx (umlsclass)
215   ((sab :type string :initarg :sab :reader sab)
216    (rel :type string :initarg :rel :reader rel)
217    (atx :type cdata :initarg :atx :reader atx))
218   (:metaclass hyperobject-class)
219   (:default-initargs :sab nil :rel nil :atx nil)
220   (:title "Associated Expression")
221   (:print-slots sab rel atx))
222
223 (defclass ucon (umlsclass)
224   ((cui :type fixnum :initarg :cui :reader cui :print-formatter fmt-cui
225         :hyperlink find-ucon-cui)
226    (pfstr :type cdata :initarg :pfstr :reader pfstr)
227    (lrl :type fixnum :initarg :lrl :reader lrl)
228    (s#term :reader s#term :subobject t)
229    (s#def :reader s#def :subobject t)
230    (s#lo :reader s#lo :subobject t)
231    (s#rel :reader s#rel :subobject t)
232    (s#coc :reader s#coc :subobject t)
233    (s#sat :reader s#sat :subobject t)
234    (s#atx :reader s#atx :subobject t)
235    (s#sty :reader s#sty :subobject t))
236   (:metaclass hyperobject-class)
237   (:default-initargs :cui nil :pfstr nil :lrl nil)
238   (:title "Concept")
239   (:print-slots cui lrl pfstr))
240
241 (defclass uxw (umlsclass)
242   ((wd :type string :initarg :wd :reader wd)
243    (cui :type fixnum :initform nil :initarg :cui :reader cui :print-formatter fmt-cui)
244    (lui :type fixnum :initform nil :initarg :lui :reader lui :print-formatter fmt-lui)
245    (sui :type fixnum :initform nil :initarg :sui :reader sui :print-formatter fmt-sui))
246   (:metaclass hyperobject-class)
247   (:default-initargs :wd nil :cui nil :lui nil :sui nil)
248   (:title "XW Index")
249   (:print-slots wd cui lui sui))
250
251 (defclass uxnw (umlsclass)
252   ((lat :type string :initarg :lat :reader lat)
253    (nwd :type string :initarg :nwd :reader nwd)
254    (cuilist :type list :initarg :cuilist :reader uxnw-cuilist))
255   (:metaclass hyperobject-class)
256   (:default-initargs :lat nil :nwd nil :cuilist nil)
257   (:title "XNW Index")
258   (:print-slots lat nwd cuilist))
259
260 (defclass uxns (umlsclass)
261   ((lat :type string :initarg :lat :reader lat)
262    (nstr :type string :initarg :nstr :reader nstr)
263    (cuilist :type list :initarg :cuilist :reader cuilist))
264   (:metaclass hyperobject-class)
265   (:default-initargs :lat nil :nstr nil :cuilist nil)
266   (:title "XNS Index")
267   (:print-slots lat nstr cuilist))
268
269
270 ;;; LEX objects
271
272 (defclass lexterm (umlsclass)
273   ((eui :type fixnum :initarg :eui :reader eui :print-formatter fmt-eui
274         :hyperlink find-lexterm-eui)
275    (wrd :type string :initarg :wrd :reader wrd)
276    (s#abr :reader s#abr :subobject t)
277    (s#agr :reader s#agr :subobject t)
278    (s#cmp :reader s#cmp :subobject t)
279    (s#mod :reader s#mod :subobject t)
280    (s#nom :reader s#nom :subobject t)
281    (s#prn :reader s#prn :subobject t)
282    (s#prp :reader s#prp :subobject t)
283    (s#spl :reader s#spl :subobject t)
284    (s#trm :reader s#trm :subobject t)
285    (s#typ :reader s#typ :subobject t))
286   (:metaclass hyperobject-class)
287   (:default-initargs :eui nil :wrd nil)
288   (:title "Lexical Term")
289   (:print-slots eui wrd))
290
291
292 (defclass labr  (umlsclass)
293   ((eui :type integer :initarg :eui :reader eui :print-formatter fmt-eui)
294    (bas :type string :initarg :bas :reader bas)
295    (abr :type string :initarg :abr :reader abr)
296    (eui2 :type integer :initarg :eui2 :reader eui2 :print-formatter fmt-eui)
297    (bas2 :type string :initarg :bas2 :reader bas2))
298   (:metaclass hyperobject-class)
299   (:default-initargs :eui nil :bas nil :abr nil :eui2 nil :bas2 nil)
300   (:title "Abbreviations and Acronyms")
301   (:print-slots eui bas abr eui2 bas2))
302
303 (defclass lagr  (umlsclass)
304   ((eui :type integer :initarg :eui :reader eui :print-formatter fmt-eui)
305    (str :type string :initarg :str :reader str)
306    (sca :type string :initarg :sca :reader sca)
307    (agr :type string :initarg :agr :reader agr)
308    (cit :type string :initarg :cit :reader cit)
309    (bas :type string :initarg :bas :reader bas))
310   (:metaclass hyperobject-class)
311   (:default-initargs :eui nil :str nil :sca nil :agr nil :cit nil :bas nil)
312   (:title "Agreement and Inflection")
313   (:print-slots eui str sca agr cit bas))
314
315 (defclass lcmp  (umlsclass)
316   ((eui :type integer :initarg :eui :reader eui :print-formatter fmt-eui)
317    (bas :type string :initarg :bas :reader bas)
318    (sca :type string :initarg :sca :reader sca)
319    (com :type string :initarg :com :reader com))
320   (:metaclass hyperobject-class)
321   (:default-initargs :eui nil :bas nil :sca nil :com nil)
322   (:title "Complementation")
323   (:print-slots eui bas sca com))
324
325 (defclass lmod  (umlsclass)
326   ((eui :type integer :initarg :eui :reader eui :print-formatter fmt-eui)
327    (bas :type string :initarg :bas :reader bas)
328    (sca :type string :initarg :sca :reader sca)
329    (psnmod :type string :initarg :psnmod :reader psnmod)
330    (fea :type string :initarg :fea :reader fea))
331   (:metaclass hyperobject-class)
332   (:default-initargs :eui nil :bas nil :sca nil :psnmod nil :fea nil)
333   (:title "Modifiers")
334   (:print-slots eui bas sca psnmod fea))
335
336 (defclass lnom  (umlsclass)
337   ((eui :type integer :initarg :eui :reader eui :print-formatter fmt-eui)
338    (bas :type string :initarg :bas :reader bas)
339    (sca :type string :initarg :sca :reader sca)
340    (eui2 :type integer :initarg :eui2 :reader eui2 :print-formatter fmt-eui)
341    (bas2 :type string :initarg :bas2 :reader bas2)
342    (sca2 :type string :initarg :sca2 :reader sca2))
343   (:metaclass hyperobject-class)
344   (:default-initargs :eui nil :bas nil :sca nil :eui2 nil :bas2 nil :sca2 nil)
345   (:title "Nominalizations")
346   (:print-slots eui bas sca eui2 bas2 sca2))
347
348 (defclass lprn  (umlsclass)
349   ((eui :type integer :initarg :eui :reader eui :print-formatter fmt-eui)
350    (bas :type string :initarg :bas :reader bas)
351    (num :type string :initarg :num :reader num)
352    (gnd :type string :initarg :gnd :reader gnd)
353    (cas :type string :initarg :cas :reader cas)
354    (pos :type string :initarg :pos :reader pos)
355    (qnt :type string :initarg :qnt :reader qnt)
356    (fea :type string :initarg :fea :reader fea))
357   (:metaclass hyperobject-class)
358   (:default-initargs :eui nil :bas nil :num nil :gnd nil :cas nil
359                      :pos nil :qnt nil :fea nil)
360   (:title "Pronouns")
361   (:print-slots eui bas num gnd cas pos qnt fea))
362
363 (defclass lprp  (umlsclass)
364   ((eui :type integer :initarg :eui :reader eui :print-formatter fmt-eui)
365    (bas :type string :initarg :bas :reader bas)
366    (str :type string :initarg :str :reader str)
367    (sca :type string :initarg :sca :reader sca)
368    (fea :type string :initarg :fea :reader fea))
369   (:metaclass hyperobject-class)
370   (:default-initargs :eui nil :bas nil :str nil :sca nil :fea nil)
371   (:title "Properties")
372   (:print-slots eui bas str sca fea))
373
374
375 (defclass lspl  (umlsclass)
376   ((eui :type integer :initarg :eui :reader eui :print-formatter fmt-eui)
377    (spv :type string :initarg :spv :reader spv)
378    (bas :type string :initarg :bas :reader bas))
379   (:metaclass hyperobject-class)
380   (:default-initargs :eui nil :spv nil :bas nil)
381   (:title "Spelling Variants")
382   (:print-slots eui spv bas))
383
384
385 (defclass ltrm  (umlsclass)
386   ((eui :type integer :initarg :eui :reader eui :print-formatter fmt-eui)
387    (bas :type string :initarg :bas :reader bas)
388    (gen :type string :initarg :gen :reader gen))
389   (:metaclass hyperobject-class)
390   (:default-initargs :eui nil :bas nil :gen nil)
391   (:title "Trade Marks")
392   (:print-slots eui bas gen))
393
394 (defclass ltyp  (umlsclass)
395   ((eui :type integer :initarg :eui :reader eui :print-formatter fmt-eui)
396    (bas :type string :initarg :bas :reader bas)
397    (sca :type string :initarg :sca :reader sca)
398    (typ :type string :initarg :typ :reader typ))
399   (:metaclass hyperobject-class)
400   (:default-initargs :eui nil :bas nil :sca nil :typ nil)
401   (:title "Inflection Type")
402   (:print-slots eui bas sca typ))
403
404 (defclass lwd (umlsclass)
405   ((wrd :type string :initarg :wrd :reader wrd)
406    (euilist :type list :initarg :euilist :reader euilist))
407   (:metaclass hyperobject-class)
408   (:default-initargs :wrd nil :euilist nil)
409   (:title "Lexical Word Index")
410   (:print-slots wrd euilist))
411
412 ;;; Semantic NET objects
413
414 (defclass sdef (umlsclass)
415   ((rt :type string :initarg :rt :reader rt)
416    (ui :type integer :initarg :ui :reader ui :print-formatter fmt-tui)
417    (styrl :type string :initarg :styrl :reader styrl)
418    (stnrtn :type string :initarg :stnrtn :reader stnrtn)
419    (def :type string :initarg :def :reader def)
420    (ex :type string :initarg :ex :reader ex)
421    (un :type string :initarg :un :reader un)
422    (rh :type string :initarg :rh :reader rh)
423    (abr :type string :initarg :abr :reader abr)
424    (rin :type string :initarg :rin :reader rin))
425   (:metaclass hyperobject-class)
426   (:default-initargs 
427    :rt nil :ui nil :styrl nil :stnrtn nil :def nil :ex nil :un nil :rh nil 
428    :abr nil :rin nil)
429   (:title "Basic information about Semantic Types and Relations")
430   (:print-slots rt ui styrl stnrtn def ex un rh abr rin))
431
432 (defclass sstr (umlsclass)
433   ((styrl :type string :initarg :styrl :reader styrl)
434    (rl :type string :initarg :rl :reader rl)
435    (styrl2 :type string :initarg :styrl2 :reader styrl2)
436    (ls :type string :initarg :ls :reader ls))
437   (:metaclass hyperobject-class)
438   (:default-initargs :styrl nil :rl nil :styrl2 nil :ls nil)
439   (:title "Structure of the Network")
440   (:print-slots styrl rl styrl2 ls))
441
442 (defclass sstre1 (umlsclass)
443   ((ui :type integer :initarg :ui :reader ui :print-formatter fmt-tui)
444    (ui2 :type integer :initarg :ui2 :reader ui2 :print-formatter fmt-tui)
445    (ui3 :type integer :initarg :ui3 :reader ui3 :print-formatter fmt-tui))
446   (:metaclass hyperobject-class)
447   (:default-initargs :ui nil :ui2 nil :ui3 nil)
448   (:title "Fully Inherited Set of Releatons (TUI's)")
449   (:print-slots ui ui2 ui3))
450
451 (defclass sstre2 (umlsclass)
452   ((sty :type string :initarg :ui :reader sty)
453    (rl :type string :initarg :ui2 :reader rl)
454    (sty2 :type string :initarg :ui3 :reader sty2))
455   (:metaclass hyperobject-class)
456   (:default-initargs :sty nil :rl nil :sty2 nil)
457   (:title "Fully Inherited Set of Releatons (strings)")
458   (:print-slots sty rl sty2))
459
460 ;;; Formatting routines
461
462 (defgeneric fmt-cui (c))
463 (defmethod fmt-cui ((c ucon))
464   (format nil "C~7,'0d" (cui c)))
465
466 (defmethod fmt-cui ((c fixnum))
467   (format nil "C~7,'0d" c))
468
469 (defmethod fmt-cui ((c string))
470   (if (eql (aref c 0) #\C)
471       c
472     (format nil "C~7,'0d" (parse-integer c))))
473
474 (defmethod fmt-cui ((c null))
475   (format nil "nil"))
476
477 (defgeneric fmt-lui (c))
478 (defmethod fmt-lui ((l uterm))
479   (format nil "L~7,'0d" (lui l)))
480
481 (defmethod fmt-lui ((l fixnum))
482   (format nil "L~7,'0d" l))
483
484 (defmethod fmt-lui ((l string))
485   (if (eql (aref l 0) #\L)
486       l
487   (format nil "L~7,'0d" (parse-integer l))))
488
489 (defgeneric fmt-sui (s))
490 (defmethod fmt-sui ((s ustr))
491   (format nil "S~7,'0d" (sui s)))
492
493 (defmethod fmt-sui ((s fixnum))
494   (format nil "S~7,'0d" s))
495
496 (defmethod fmt-sui ((s string))
497   (if (eql (aref s 0) #\S)
498       s
499   (format nil "S~7,'0d" (parse-integer s))))
500
501 (defgeneric fmt-tui (t))
502 (defmethod fmt-tui ((s fixnum))
503   (format nil "T~3,'0d" s))
504
505 (defmethod fmt-tui ((s string))
506   (if (eql (aref s 0) #\T)
507       s
508   (format nil "T~3,'0d" (parse-integer s))))
509
510 (defgeneric fmt-eui (e))
511 (defmethod fmt-eui ((e fixnum))
512   (format nil "E~7,'0d" e))
513
514 (defmethod fmt-eui ((e string))
515   (if (eql (aref e 0) #\E)
516       e
517     (format nil "E~7,'0d" (parse-integer e))))
518
519 (defmethod fmt-eui ((e null))
520   (format nil "nil"))
521
522 ;;; Generic display functions
523
524 (eval-when (:compile-toplevel :load-toplevel :execute)
525 (defun english-term-p (obj)
526   "Returns two values: T/NIL if term is english and T/NIL if obj is a TERM"
527   (if (eq (hyperobject::class-name (hyperobject::class-of obj)) 'uterm)
528       (values (string-equal (lat obj) "ENG") t)
529     (values nil nil))))
530
531
532 (defgeneric print-umlsclass (obj &key os format label file-wrapper english-only subobjects refvars)
533   )
534
535 (defmethod print-umlsclass ((obj umlsclass) &key (os *standard-output*) (format :text)
536                               (label nil) (file-wrapper t) (english-only nil) (subobjects nil)
537                               (refvars nil))
538   (view obj :os os :format format :label label :subobjects subobjects
539         :file-wrapper file-wrapper
540         :english-only-function (if english-only #'english-term-p nil)
541         :refvars refvars))
542
543
544 (defmacro define-lookup-display (newfuncname lookup-func)
545   "Defines functions for looking up and displaying objects"
546   `(defun ,newfuncname  (keyval &key (os *standard-output*) (format :text) (label nil)
547                                 (file-wrapper t) (english-only nil) (subobjects nil))
548      (let ((obj (funcall ,lookup-func keyval)))
549        (print-umlsclass obj :os os :format format :label label 
550                         :file-wrapper file-wrapper :english-only english-only
551                         :subobjects subobjects)
552        obj)))
553
554 (define-lookup-display display-con #'find-ucon-cui)
555 (define-lookup-display display-term #'find-uterm-lui)
556 (define-lookup-display display-str #'find-ustr-sui)
557
558 #+(or scl cmu)
559 (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))
560     #+cmu
561     (let ((cl (pcl:find-class c)))
562       (pcl:finalize-inheritance cl))
563     #+scl
564     (let ((cl (find-class c)))
565       (clos:finalize-inheritance cl)))