Saving the Context

The context from a Brainhat session can be saved and resurrected at a later time. Below, we interact with Brainhat.  Upon exit, the context is saved.  We start Brainhat a second time and restore the context.  Then, we check to see that the context has been restored.

Save the context

To tell Brainhat that we want to save the context, we invoke it with the -S flag, like so:

$ ./brainhat -S /tmp/foo.mbin +repeat

>> hello
>> i like you 
 You like Me.
>> i think that we are friends
 You believe we are friend.
>> i want you to come to my house
 You want I come to your house.
>> i have a dog
 You have a dog.
>> my dog's name is sparky
 sparky is sparky.
>> sparky likes bones
 sparky likes bone.
>> bye

The 'S' means "save."  The location of the save-set is /tmp/foo.mbin.  The +repeat flag asks Brainhat to echo our input.

Restore the context

We use the -R flag to restore the context:

$ ./brainhat -R /tmp/foo.mbin +repeat

>> what is my dog's name?
 sparky is sparky.
>> what do i think?
 You believe we are friend.
>> bye


Inspect the context

We can inspect the context by going into debug.  The 'xspeak 1' command will ask Brainhat to show you 20 context entries starting with the first one:

$ ./brainhat -R /tmp/foo.mbin +repeat

>> break

Break in debug at the start:
debug> xspeak 1
 You say sparky likes bone. You say hello. You like Me. You say You like Me. You believe we are friend. You say You believe we are friend. You want I come to your house. You say You want I come to your house. You have sparky. You say You have sparky. sparky is sparky. You say sparky is sparky. sparky likes bone.

debug> exit

>> bye


One thing to be aware of: if you modify the vocabulary or rulebase, you may change the tag numbers of the concepts.  This will cause a mismatch between the concept numbers in the saved context and the vocabulary.  There is a facility for automatically reserving tag numbers for concepts so that this does not happen.  We will see how to use it in another how-to.