r7859: add new function
[umlisp.git] / sql-classes.lisp
index 52b9ce8873e9f4646b4200b205dbd6460b66262a..2adc2d81e1a9d6703ae37593b16ad427d21526ba 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Author:        Kevin M. Rosenberg
 ;;;; Date Started:  Apr 2000
 ;;;;
-;;;; $Id: sql-classes.lisp,v 1.89 2003/07/21 09:46:22 kevin Exp $
+;;;; $Id$
 ;;;;
 ;;;; This file, part of UMLisp, is
 ;;;;    Copyright (c) 2000-2003 by Kevin M. Rosenberg, M.D.
@@ -256,6 +256,12 @@ is OBJNAME from TABLE where WHERE-NAME field = WHERE-VALUE with FIELDS"
                   :pfstr kpfstr
                   :lrl (ensure-integer kcuilrl))))
 
+(defun find-ucon-cui-all (&key (srl *current-srl*))
+  "Return list of CUIs for all ucons"
+  (collect-umlisp-query (mrcon (cui) srl nil nil :order (cui asc)
+                              :distinct t)
+                       cui))
+
 (defun map-ucon-all (fn &key (srl *current-srl*))
   "Map a function over all ucon's"
   (with-sql-connection (db)
@@ -553,6 +559,24 @@ is OBJNAME from TABLE where WHERE-NAME field = WHERE-VALUE with FIELDS"
                                      :lrl 'klrl :order '(cui asc))
     (find-ucon-cui cui :srl srl)))
 
+(defun find-cui-normalized-word (word &key (srl *current-srl*) (like nil))
+  "Return list of cui that match word, optionally use SQL's LIKE syntax"
+  (collect-umlisp-query-eval ('mrxnw_eng '(cui) srl 'nwd word :like like :distinct t
+                                        :lrl 'klrl :order '(cui asc))
+                            cui))
+
+(defun find-lui-normalized-word (word &key (srl *current-srl*) (like nil))
+  "Return list of cui that match word, optionally use SQL's LIKE syntax"
+  (collect-umlisp-query-eval ('mrxnw_eng '(lui) srl 'nwd word :like like :distinct t
+                                        :lrl 'klrl :order '(cui asc))
+                            lui))
+
+(defun find-sui-normalized-word (word &key (srl *current-srl*) (like nil))
+  "Return list of cui that match word, optionally use SQL's LIKE syntax"
+  (collect-umlisp-query-eval ('mrxnw_eng '(sui) srl 'nwd word :like like :distinct t
+                                        :lrl 'klrl :order '(cui asc))
+                            sui))
+
 (defun find-ustr-word (word &key (srl *current-srl*))
   "Return list of ustrs that match word"
   (collect-umlisp-query (mrxw_eng (cui sui) srl wd word :lrl klrl
@@ -717,9 +741,9 @@ is OBJNAME from TABLE where WHERE-NAME field = WHERE-VALUE with FIELDS"
     (make-instance 'ltyp :eui eui :bas bas :sca sca :typ typ)))
 
 (defun find-lwd-wrd (wrd)
-  (make-instance 'lwd :wrd
+  (make-instance 'lwd :wrd wrd
                 :euilist (collect-umlisp-query (lrwd (eui) nil wrd wrd)
-                           (ensure-integer eui))))
+                                               (ensure-integer eui))))
 
 ;;; Semantic Network SQL access functions
 
@@ -833,15 +857,14 @@ is OBJNAME from TABLE where WHERE-NAME field = WHERE-VALUE with FIELDS"
      (make-instance 'bsab :sab sab :name name :hits (ensure-integer count))))
 
 (defun find-btty-tty (tty)
- (:collect-umlisp-query (bonus_tty (name count) nil tty tty :single t)
+ (collect-umlisp-query (bonus_tty (name count) nil tty tty :single t)
      (make-instance 'btty :tty tty :name name :hits (ensure-integer count))))
 
 (defun find-btty-all ()
- (u::collect-umlisp-query (bonus_tty (tty name count) nil nil nil :order (tty asc))
+ (collect-umlisp-query (bonus_tty (tty name count) nil nil nil :order (tty asc))
   (make-instance 'btty :tty tty :name name :hits (ensure-integer count))))
 
 (defun find-brel-rel (rel)
-  (u::collect-umlisp-query (bonus_rel (sab sl rel rela count) nil rel rel)
-     (make-instance 'brel :sab sab :sl sl :rel rel :rela rela
+  (collect-umlisp-query (bonus_rel (sab sl rel rela count) nil rel rel)
+    (make-instance 'brel :sab sab :sl sl :rel rel :rela rela
                    :hits (ensure-integer count))))
-