;; ======================================================================= ;; implements lexical search of clib index file ;; ;; dgt 09/16/05 ;; ======================================================================== (unless (find-package :km) (make-package :km))(in-package :km)(setq *using-km-package* t) (load "/usr/spool/net/www/users/mfkb/RKF/smedict/index-entry.lisp") ;; returns a list of components that match keyword ;; result = (km-path spec-path dist depth) ;; for lexical search dist = 0 for exact match, maxint for approx (defun lexical-search (keyword) (let ((results)) (dolist (entry *component-index*) ;; entry = ((wordnet-keyword sense# pos synset#) comp-keyword depth km-path spec-path) (multiple-value-bind (matched whole-match comp) (excl::match-regexp (concatenate 'string ".*\\(" keyword "\\).*") (index-entry-comp-name entry) :case-fold t) (if matched (push (list (index-entry-comp-name entry) (index-entry-depth entry) "-" (if (string= whole-match comp) 0 0.5)) results)))) results))