How do I specify a knowledge base within a server?

This process is done in two stages. OKBC allows there to be multiple types of KB available on any server, and KBs are categorized under these KB-types. This means that before we can pick a KB, we must pick a KB-type. This is done simply by asking the server for the list of KB-types. Each of these KB-types has a name that identifies the KRS used.

Once you know the KB-type, you can specify a KB by using open-kb. A required argument of this function is the kb-locator which is the portable way to specify the location of a KB. It is created by create-kb-locator (thing kb-type connection) which returns a new kb-locator associated with thing for a kb of type kb-type. Thing is a kb-type and connection specific specification of a KB location sufficient to create and fully initialize a KB locator.

Each back-end implementation must provide documentation for all values of thing accepted. For instance, in the case of an Ocelot file KB the locator contains the name of the KB and the pathname of the file on which the KB resides

USER(1): (setf kb-type (okbc:get-kb-type 'ok-back:ocelot-file-kb))
#< OK-BACK:OCELOT-FILE-KB Prototype @ #x1719a72>
USER(2): (setf kb-locator
  (okbc:create-kb-locator '(:name TEST2 :pathname "~/kbs/y.kb")
                          :kb-type kb-type
                          :connection (okbc:local-connection)))
USER(3): (setf kb
  (okbc:open-kb kb-locator 
                :kb-type kb-type
                :connection (okbc:local-connection)))
[Loading Ocelot KB from ~/kbs/y.kb
 KB name=TEST2, package=COMMON-LISP-USER

 9 frames loaded]
#< OK-BACK:OCELOT-FILE-KB TEST2 @ #x1daf4ca>
USER(4): (okbc:goto-kb kb)
USER(5): (okbc:get-kb-frames)
 < Class ANIMAL> < Class VEGETAL> < Class COW> < Class HERB> < Instance EAT>
 < Instance EATEN-BY> < Instance :CARDINALITY> ...)

Next: What happens if a connection is lost?
Top: OKBC FAQ Table of Contents