KWI Reference


Preparing to Run a Knowledgebase

Before the knowledgebase can be run, the KWI must be initialized, a knowledgebase file opened and session started. The following KWI calls provide those services.

initialize

kwi(0, initialize([directory = <kb_pathname>, session_directory = <session_pathname>, log_file = <log_file>, message_level = <level>, goals=<list>]), INFO)

Parameters:

Returns the property list INFO containing:

Initializes the reasoning engine.

Examples:

kwi(session0, initialize([directory = $" + doubleSlashes(App.path) + "\\$, 
                              session_directory = $" + doubleSlashes(App.path) + "\\$, 
                              log_file = $vbrun.log$, 
                              message_level = high]), INFO)
INFO = [system = $basic$, version = $4-1-1$]

kwi(session0, initialize([directory = $" + doubleSlashes(App.path) + "\\$,
                              session_directory = $" + doubleSlashes(App.path) + "\\$]), INFO)
INFO = [system = $sales$, version = $4-2-2$]

open

kwi(0, open(<knowledgebase_file>), _)

Parameters:

Returns:

Opens the specified knowledgebase file.

Examples:

kwi(session0, open($amzi_website_advisor.kb$), _)

new_session

kwi(<id>, new_session, _)

Parameters:

Returns:

Creates a new reasoning session with the specified identifier. The identifier is used in all subsequent KWI calls.

Examples:

kwi(s22, new_session, _)

Running the Knowledgebase

solve

kwi(<id>, solve, MORE)

Parameters:

Returns:

Tells the inference engine to start or continue reasoning. After each call to solve, get_action needs to be called and acted upon until there are no more actions.

Examples:

kwi(session0, solve, MORE)
MORE = more

kwi(s22, solve, MORE)
MORE = no_more

Interacting with the User

get_action

kwi(<id>, get_action, ACTION)

Parameters:

Returns the property list ACTION containing:

Returns an action to be performed. It can be a question to ask the user, in which case the reasoning engine expects an KWI assert to tell the reasoning engine what the user answered. The action can also be a conclusion the reasoning engine has determined is true. If that conclusion is associated with a text object, the fields of that object are returned.

Examples:

kwi(session0, get_action, ACTION)
ACTION = ask(user, [prompt = $What are your favorite colors?$,
                    question_type = menu_multiple_choices,
                    choices = [$red$, $orange$, $yellow$, $green$, $blue$, $idigo$, $violet$] ])

kwi(s22, get_action, ACTION)
ACTION = tell(user, [goal = $moods$, 
                     text = $Your colors indicate you are in a good mood.$] )

Asserting New Fact Values

kwi(<id>, assert(fact(<name>, <value>)), _)

Parameters:

Returns:

Asserts a new fact value for the reasoning engine to use. String values should be passed in $'s. Lists of values are passed in square brackets, separated by commas (also quoted if necessary).

Examples:

kwi(session0, assert(fact(age, 33)), _)
kwi(s22, assert(fact(colors, [$blue$, $orange$, $violet$])), _)


Copyright ©1996-2002 Amzi! inc. All Rights Reserved. Amzi! and WebLS are registered trademarks and KnowledgeWright, Logic Server are trademarks of Amzi! inc.