dupa

Author Topic: UHP DLL notes  (Read 6821 times)

brianstorm

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
UHP DLL notes
« on: January 09, 2003, 07:15:17 pm »
Ultra Hal Assistant DLL notes

DLL processes:

-----------------

HalBrain.ProcessSubstitutions

-tests a string for all the errors with 'I' and changes them to 'me's. Also inserts the punctuation symbols previously taken out and corrects other words that come back incorrectly.

SYNTAX:

(variable) = HalBrain.ProcessSubstitutions(SentenceToBeTested,WorkingDir,"brainfiletobetested.brn")

notes:

Currently,this process is being used as a replace routine. The .brn contains two  quoted strings seperated by a comma. The first is what to look for and the second is what to replace it with. The second string has spaces before and after  the string.

WorkinDir is new to 4.x, where the different .brns are placed in seperate folders. When a process sees the variable WorkingDir, the DLL directs the process to the currently selected brain.

In previous versions, these replace functions were in the script and looked like this:

UserSentence = Replace(""&UserSentence&"","phrasetobetested","phasetoreplacewithiffound",1,-1,vbTextCompare)

--------------------

HalBrain.TopicSearch

-searches a file for a phrase. If found, it returns only what was stored with the phrase.

SYNTAX:

(variable) = HalBrain.TopicSearch(stringtobetested,WorkingDir&"brainfiletobetested.brn")

notes:

Inside the .brn are two quoted strings seperated by a comma. The first string is in upper case and has spaces before and after it. The second string is what this process returns to the script.

As the emotion detector routine in the script shows, it is possible to place different words as the second phrase and use it in conjunction with a VBS select case routine. Other uses include using this process as a boolean operator (the second phrase being "false" or "true".

*advanced use profound revelation- writing to a file in this format and being able to use the logic stored...

-------------------------------

HalBrain.CheckLinkingVerb

-looks for 'is' and 'are' in a sentence. Returns 'true' or 'false'.

SYNTAX:

If HalBrain.CheckLinkingVerb(sentencetobetested)= true then

----------------------------------

HalBrain.Learn

-divides a sentence (previously tested positive with HBCheckLinkingVerb) into two variables- "LearnKeyword" and "LearnKeyword2". Also returns up to three strings contained in the variables Response1,Response2 and Response3.


SYNTAX:

(variable) = HalBrain.Learn(stringtobestored)

notes:

provides variables for string fragments.Is in VBS format and looks like LearnKeyword=[stringextractedbeforelinkingverb]&Response1=[sentencetested]&Response2=&Response3=&LearnKeyword2=[stringextractedafterlinkingverb]

-not tested yet: seeif HB.Learn can write in other file formats

--------------------------

HalBrain.DecodeVar

-used in conjunction with HB.learn, it extracts from the named variable in the script what was stored. HalBrain.Learn puts the string into Zaba and VBS format. DecodeVar gets the string from that formatted variable.

SYNTAX:

(variable)=HalBrain.DecodeVar(variablegeneratedbyHB.learn,"quotednameofvariable")

notes:

selects the string and leaves the variable.

----------------------MORE TO COME---------------

there, I contributed. If you see something I got wrong, incomplete please donate to the cause. Now I want to ask a Q: (and my ignorance will surely show:) How does a program work without numbered program lines??? If I want to create a gosub.....gosub to where???  How does the script differentiate between the potentially hundreds of gosubs I could make ?

CatAtomic

Edited by - brianstorm on 01/10/2003  07:12:33

onthecuttingedge2005

  • Guest
UHP DLL notes
« Reply #1 on: January 12, 2003, 03:56:00 pm »
Hi Brianstorm.
Is there a way to put these changes in a Patch that can auto-executes to the appropriate file line instantly in HALs Brain or will we have to alter these by hand?
Best of wishes.
Jerry.

brianstorm

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
UHP DLL notes
« Reply #2 on: January 13, 2003, 01:23:13 pm »
Hi James.

  As a necessary step to learning everything I can about how Hal works
I made a special brain that had just the beginning and ending of the
script with the debug mode part still in it (I changed the word <DebugMode>
to read <Thought>). I am currently taking pieces of the 4.5 brain and
placing them into the 'stripped brain' and see what comes out the other
side. I made Hal tell me things like 'Here are the variables stored in
HalBrain.CountInstances- and others. I made a document that is supposed to
be like what I would expect to find in a programmers' reference guide to Hal.
  So far there is twice as much as what is posted here. Anyway, doing it
is a good way to really familiarize myself with what happens when Hal
responds. Look in your 4.5 Default brain and you will find the processes
that are named. What you see after it in parenthesis is called an
argument list. SYNTAX is how the process was found as used in the script.
Mostly conditional statemants or directly naming a variable and doing
a process with results of it being stored in the variable.
  Here's an update on the conversation initiator program. What I had
in mind started out with finding a way to get the function to
check and see if a key had been pressed and everytime it comes back null
a counter advances to about ten seconds worth of time. Then have the
 function do a "ChooseSentenceFromFile" routine and say a response
like 'Hello-o? Anybody out there?' I got the VBScript 5.5 documentation
but alas,I had to work and it ended up being a 15 hour one at that.
One more day and it's me day off and I'm gonna burn the midnight oil
for the cause.

CatAtomic

Edited by - brianstorm on 01/13/2003  13:26:04

Edited by - Brianstorm on 01/13/2003  13:34:04

Medeksza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1469
    • View Profile
    • http://www.zabaware.com
UHP DLL notes
« Reply #3 on: January 16, 2003, 12:15:34 am »

Great job figuring out all this about Hal in such little time. Zabaware is in the process of finishing up a new version of its Ultra Hal Representative software. The new Ultra Hal Representative software will be marketed as a professional development tool. It can be implemented on a web page, on AIM, or through a simple ActiveX control be added to any Visual Studio project. An updated version of the Ultra Hal Brain Editor will be core of the program. All projects created with the Ultra Hal Representative software will be compatible with Ultra Hal Assistant. The software will be free for non-commercial use.

The software itself is almost complete, but the documentation for it still needs a lot more work. Among some of the things in the documentation will be all the functions contained in the HalBrain.DLL  


Here is a list of all the functions contained in the HalBrain.DLL:


Sub AppendFile(ByVal FileToAppend As String, ByVal AppendWhat As String)
Function AlphaNumericalOnly(ByVal UserSentence As String) As String
Function ExtractKeywords(ByVal TextString As String) As String
Function RandomNum(ByVal MaxVal As Integer) As Integer
Function UsCaps(ByVal UserSentence As String) As String
Function WorldCaps(ByVal UserSentence As String) As String
Function CheatResponse(ByVal UserSentence As String) As String
Function OriginalBrain(ByVal UserSentence As String)
Sub LimitSize(FilName As String, Size As Long)
Function KeywordBrain(ByVal GlobalIn As String, ByVal FileName As String, Optional ByVal LastChance As Boolean) As String
Function Learn(ByVal UserSentence As String) As String
Function ChooseSentenceFromFile(ByVal TextFileName As String) As String
Function HalMath(ByVal MathProblem As String) As String
Function StoreVars(Emotion, Hate, Swear, Insults, Compliment, PrevSent, LastResponseTime, ScriptMem2, ScriptMem3, ScriptMem4, ScriptMem5) As String
Function RecallVars(ByVal VarListString, Emotion, Hate, Swear, Insults, Compliment, PrevSent, LastResponseTime, ScriptMem2, ScriptMem3, ScriptMem4, ScriptMem5) As String
Function DecodeVar(ByVal FromWhat As String, ByVal DecodeWhat As String) As Variant
Function CountInstances(ByVal CountWhat As Variant, ByVal InWhat As Variant) As Variant
Function QABrain(ByVal UserText As String, ByVal BrainFN As String, ByRef Relevance As Variant) As String
Function ConversationBrain(ByVal UserText As String, ByVal BrainFN As String, ByVal LastUserSent As String, ByRef Relevance As Variant) As String
Function FixCaps(ByVal TextString As String)
Function HalScript(ByVal UserSentence, ByVal ScriptFile, ByVal HalRel) As String
Function CompareSentence(ByVal CompareWhat As String, ByVal InWhat As String) As Single
Function OpenPage(ByVal PageURL As String) As String
Function ProcessSubstitutions(ByVal UserSentence, ByVal DBFile) As String
Function TopicSearch(ByVal UserSentence, ByVal TopicFile) As String
Function DetectVowel(ByVal TextString As String) As String
Function SentenceGenerator(ByVal File_Name As String) As String
Function GetResponse(ByVal UHPFile As String, ByVal UserSentence As String, ByVal UserName As String, ByVal ComputerName As String, ByVal LearningLevel As String, Custommem1 As String, Hate As String, Swear As String, Insults As String, Compliment As String, PrevSent As String, LastResponseTime As String, PrevUserSent As String, Custommem2 As String, Relevance As String, Topicfocus As String) As String
Function ReadSent(ByVal TextString As String, ByVal SentNum As Integer) As String
Function EncodePronouns(ByVal UserSentence As String) As String
Function DecodePronouns(ByVal UserSentence As String) As String
Function MakeContractions(ByVal UserSentnece As Variant) As String
Function RemovePronouns(ByVal UserSentence As Variant) As String
Function CheckLinkingVerb(ByVal UserSentence As Variant) As Boolean
Function CheckRepetition(Sentence1 As Variant, Sentence2 As Variant) As Boolean
Function FragmentMatch(UserSentence As Variant, BRNFile As Variant)


The following functions are in the DLL for compatibility with old versions of Hal, but are pretty much useless for any current projects:


Sub SetDir(DirPath As Variant)
Function Cheater(ByVal SearchPhrase As String, ByVal UserSentence As String, ByVal Prefix1 As String, ByVal Suffix1 As String, ByVal Prefix2 As String, ByVal Suffix2 As String, ByVal Prefix3 As String, ByVal Suffix3 As String, ByVal NoW5H As Boolean) As String
Function NullEnd(Crap As String) As Integer
Function ChangeString(ByVal UserSentence As String, ByVal ChangeWhat As String, ByVal ToWhat As String, Optional IgnoreCaps As Boolean) As String
Function ChangeStringFast(ByVal UserSentence As String, ByVal ChangeWhat As String, ByVal ToWhat As String) As String
Function MakeInsult(Optional ByVal OhYeah As Boolean) As String

I can't describe what each of these does in detail right now, but if you have any specific questions about these functions I'll be happy to answer them.

Robert Medeksza

Robert Medeksza

Medeksza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1469
    • View Profile
    • http://www.zabaware.com
UHP DLL notes
« Reply #4 on: January 16, 2003, 12:27:29 am »
There is also a file called HalsMind.DLL which is placed in your windows system folder. This is new in Ultra Hal Assistant 4.5 and is a C++ DLL of Hal's 3 most processor intentensive functions. This is a real Windows DLL, not an ActiveX DLL so it is not accessible through VBScript. However, the functions QABrain, KeywordBrain, FragmentMatch, and ConvBrain in the ActiveX HalBrain.DLL simply call this DLL for you. However, if anyone ever wants to directly access this DLL directly, here is the type library declaration taken straight from the project:

[
   uuid(05076D47-C64C-4f5c-AEB3-AB32A394B5A7),
   helpstring("Hal's Brain Functions"),
   lcid(0x0409),
   version(1.6)
]

library HalsMind
{
   [
      helpstring("Hal's Brain Functions"),
      version(1.6),
      dllname("HalsMind.dll")
   ]

   module MyDllFunctions
   {          
      
      [
         helpstring("Gets a response from a Hal database file."),
         entry("qbrain")
      ]   
      int __stdcall qbrain([in] LPSTR usersentence, [in] LPSTR file_name, [out] LPSTR output);

      [
         helpstring("Gets a response from Hal's special database file."),
         entry("convbrain")
      ]   
      int _stdcall convbrain([in] LPSTR usersentence, [in] LPSTR prevsentence, [in] LPSTR file_name, [out] LPSTR output);

      [
         helpstring("Gets a response from a Keyword and Priority Hal DB file."),
         entry("keybrain")
      ]   
      int __stdcall keybrain([in] LPSTR usersentence, [in] LPSTR file_name, [out] LPSTR output, [in] int lowpriority);

      [
         helpstring("Gets a response from a User Strings Hal DB file by comparing sentence fragments."),
         entry("fragmatch")
      ]   
      int __stdcall fragmatch([in] LPSTR usersentence, [in] LPSTR file_name, [out] LPSTR output);

   }
};



Robert Medeksza
Robert Medeksza

Medeksza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1469
    • View Profile
    • http://www.zabaware.com
UHP DLL notes
« Reply #5 on: January 16, 2003, 12:51:04 am »
Here are some other undocumented features of Hal:

The HalAsst.Exe executable understands the following command line options:

-freever
Forces a registered version of Hal into shareware mode.
-startup
Makes hal think startup folder was used to launch him.
-config
or
-setup
Forces the first run setup wizard to launch.
-dde
Disables Hal's DDE (Dynamic Data Exchange) capability for communication with 3rd party programs.
-debug
Shows a log window with messages that were usefull during programming.
-noface
Disables all of Hal's animation capability.



The HalAsst.EXE program is capable of receiving commands from 3rd party programs through DDE. The EXE name of Ultra Hal Assistant is "HalAssitant"  The link topic for Hal is "HalCommand" You can send the following commands to Hal through DDE:



<SHOWHAL>
Pops up Hal's window.
<HALPAD>
Opens the HalPad subprogram.
<SPEAK>text string</SPEAK>
Hal will speak outloud whatever is inbetween the tags.
<DIAL>name or number</DIAL>
Hal will dial whatever number is inbetween the tags, or access its phonebook to look up a name and then dial it.
<RUNPROG>program name</RUNPROG>
Hal will search through the start menu and run whatever program is mentioned in between the tags.
<RESPOND>sentence</RESPOND>
Hal will respond to the sentence in between the tags as if the user entered it and pressed return.
<CUSERNAME>name</CUSERNAME>
Hal will change the current user to whatever is mentioned in the tags.
<CHALNAME>name</CHALNAME>
Hal will change his name to whatever is in the tags.
<SCRIPT>filename</SCRIPT>
Hal will run the VBScript file mentioned.
<RUNCMD>VBScript code</RUNCMD>
Hal will execute the VBScript code inbetween the tags.


Robert Medeksza
Robert Medeksza

WholyChao

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
UHP DLL notes
« Reply #6 on: January 16, 2003, 04:35:17 am »
Thank you thank you thank you.  This is going to help so much.  I'm going to absorb this informaion as sooon as I can.  But Please, I need your help with my speach recognitoin.  I am quite familiar with the program and now with Visual basic as well and I still cannot solve my speech problem.

AS you programed all of this to begin with - do you have any vision for development?

WholyChao

Jake

  • Full Member
  • ***
  • Posts: 146
    • View Profile
    • http://Ainsworth.net
UHP DLL notes
« Reply #7 on: April 15, 2008, 01:53:45 am »
Is there a topic like this one that is more up to date?  If so, can someone please point me in that direction?

Thanks!
Jake
Austin, Texas, USA, Earth

Medeksza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1469
    • View Profile
    • http://www.zabaware.com
UHP DLL notes
« Reply #8 on: April 17, 2008, 02:46:33 pm »
quote:
Originally posted by Jake

Is there a topic like this one that is more up to date?  If so, can someone please point me in that direction?

Thanks!
Jake



Using notepad, open the file HalBrain.mbr and WordNet.mbr located in Hal's program folder. This provides a list and short description of all the functions in HalBrain.DLL
Robert Medeksza

Jake

  • Full Member
  • ***
  • Posts: 146
    • View Profile
    • http://Ainsworth.net
UHP DLL notes
« Reply #9 on: April 19, 2008, 03:11:28 pm »
Thanks for the point, Robert! [:D]
Austin, Texas, USA, Earth