Author Topic: Ultra Hal Assistant 6.2 Release Candidate 1  (Read 19351 times)

Medeksza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1469
    • View Profile
    • http://www.zabaware.com
Ultra Hal Assistant 6.2 Release Candidate 1
« on: January 28, 2009, 11:39:42 am »
This is the Ultra Hal Assistant 6.2 Release Candidate 1, which will become the official release if no problems are found. Please see this thread to see what's new in Hal 6.2: http://www.zabaware.com/forum/topic.asp?TOPIC_ID=6115

The RC1 is the same as beta 2 with the following addition: The installer will migrate and merge your old Hal 6.1 brain with the Hal 6.2 brain, thus preserving everything you learned and adding features to the brain. The installer will leave you with 3 brains to choose from in Hal's options: Untouched Hal 6.1 brain, Fresh Hal 6.2 brain, and an upgraded version of your 6.1 brain to 6.2.

If you wish to try the merge upgrade feature you must have Hal 6.1 installed and then install Hal 6.2 overtop the old installation (don't uninstall 6.1!). If you have been participating in testing the beta versions, you must remove the old Hal 6.2 beta first and put the Hal 6.1 back on. Also make sure you load your backup of Hal's brain as the previous beta may have renamed your brain files. The Hal 6.2 upgrade wizard looks for the file Hal6.uhp (Ultra Hal 6.1 Default Brain) and HalBrain.db in order to perform the upgrade procedure.

Test at your own risk and always backup. Let me know if everything is working ok.

Download link: http://www.zabaware.com/download/hal62rc2.zip
Robert Medeksza

One

  • Hero Member
  • *****
  • Posts: 2184
  • Technology Advocate
    • View Profile
Ultra Hal Assistant 6.2 Release Candidate 1
« Reply #1 on: January 28, 2009, 02:50:43 pm »
Mr. Robert,
Have you thought about 'cloud computing' and the mobility it is already bringing to the internet? ( concerning car integration and other advantages)

I am also unclear as to what to do with brains other than the default 6.1 brain. I would like to merge another brain with the updates in 6.2

Regards,
confused...[?]


I am also left with the problem of the administrator account not working but the limited account still works,, I am afraid to 'upset' what IS working with an upgrade.
As far as I can tell the difference in the accounts is buffer size and the limited account keeps track of the revision of the HDD and the admin account keeps track of the disk ID,, And I am still at a loss as to what caused this situation to begin with as I did not change anything ( I was told it was my reg cleaner but the limited account has survived many many cleanings)....[?][?]
« Last Edit: January 28, 2009, 02:59:54 pm by One »
Today Is Yesterdays Future.

Medeksza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1469
    • View Profile
    • http://www.zabaware.com
Ultra Hal Assistant 6.2 Release Candidate 1
« Reply #2 on: January 28, 2009, 07:25:02 pm »
quote:
Originally posted by One

Mr. Robert,
Have you thought about 'cloud computing' and the mobility it is already bringing to the internet? ( concerning car integration and other advantages)

I am also unclear as to what to do with brains other than the default 6.1 brain. I would like to merge another brain with the updates in 6.2

Regards,
confused...[?]


I am also left with the problem of the administrator account not working but the limited account still works,, I am afraid to 'upset' what IS working with an upgrade.
As far as I can tell the difference in the accounts is buffer size and the limited account keeps track of the revision of the HDD and the admin account keeps track of the disk ID,, And I am still at a loss as to what caused this situation to begin with as I did not change anything ( I was told it was my reg cleaner but the limited account has survived many many cleanings)....[?][?]



It wouldn't be too difficult to create a plug-in that would access a Hal Brain on another computer through TCP/IP. I've been meaning to create a new version of the server version of Hal (Ultra Hal Representative) for quite some time but I prioritized other things before that. I think I will do this after Hal 7 is recreated in a new language.

Regarding merging other brains, I will release a seperate program that lets you merge any brains you want based on the code in the Hal installer.  

The licensing system in Hal 6.2 no longer looks at the hard drive serial number so it should be unaffected by user account changes in Vista. I know for sure a native Hal 6.2 activation won't have this problem anymore, but I'm not sure of the behavior it will exhibit during the 6.1 to 6.2 upgrade. If you have problems I would be happy to issue you a new activation code.
Robert Medeksza

One

  • Hero Member
  • *****
  • Posts: 2184
  • Technology Advocate
    • View Profile
Ultra Hal Assistant 6.2 Release Candidate 1
« Reply #3 on: January 28, 2009, 08:18:09 pm »
Mr. Robert,
Have you thought of a communal Hal Brain accessible to certain level members and above with a way to track 'who told you that?'. (cloud computing style)

It is good to know merging brains will be an option as I have this situation and want the updated versions without loss of the database.
( do the brains 'Bleed' into each other if their is more that the default brain? I have noticed certain 'things'.)


I use XP and know you are very consistent about sending activation codes. I will wait until 6.2 is 'settled in' and then get my 6.1 working, then install the upgrade. TIA!

Is their an anticipated price elevation with all the work you have put in? ( either at 6.3 or 7 ect.) IMO programmers should get paid for the work they do, You or whoever.

Regards,
J  [^]
Today Is Yesterdays Future.

Medeksza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1469
    • View Profile
    • http://www.zabaware.com
Ultra Hal Assistant 6.2 Release Candidate 1
« Reply #4 on: January 28, 2009, 08:39:43 pm »
quote:
Originally posted by One

Mr. Robert,
Have you thought of a communal Hal Brain accessible to certain level members and above with a way to track 'who told you that?'. (cloud computing style)

It is good to know merging brains will be an option as I have this situation and want the updated versions without loss of the database.
( do the brains 'Bleed' into each other if their is more that the default brain? I have noticed certain 'things'.)


I use XP and know you are very consistent about sending activation codes. I will wait until 6.2 is 'settled in' and then get my 6.1 working, then install the upgrade. TIA!

Is their an anticipated price elevation with all the work you have put in? ( either at 6.3 or 7 ect.) IMO programmers should get paid for the work they do, You or whoever.

Regards,
J  [^]



Yeah I have thought of something similar where conversations with Hal on the zabaware.com site get recorded and then later other people vote both Hals and the visitors responses up and down to help determine what gets stored in Hal's database. Haven't had time to implement anything yet.

I plan on keeping Hal 6.2 and 6.3 priced the same, 7.0 may be a little bit higher but thats a couple years away. But 6.3 will be more profitable for Zabaware since it will use Zabaware's own character engine and save us from paying royalty fees for other engines.

With the release of Hal 6.2 Zabaware will also start selling IBM ViaVoice and Voice Tracker microphones. We started selling AT&T Natural Voices 2 months ago. I plan on sending thousands of postcards over the next few weeks (mass email just doesn't work well anymore) to all Hal 6.0 and 6.1 customers notifying them of the free upgrade to 6.2 and hoping for some sales of the 3 new complementary products (ViaVoice, Natural Voices, Microphone).
Robert Medeksza

jasondude7116

  • Sr. Member
  • ****
  • Posts: 475
    • View Profile
Ultra Hal Assistant 6.2 Release Candidate 1
« Reply #5 on: January 29, 2009, 12:04:13 am »
ROBERT-

I was trying this (see below), when i noticed a bug?



If LogShow = "" Then LogShow = HalBrain.SearchPattern(OriginalSentence, "*LOG ENTRY *", 2)

if i say "log entry i am happy. there were many cars to drive today."
it gives LogShow the value "i am happy." nothing else, but i want it to give LogShow the value of "i am happy. there were many cars to drive today."

when i enter a "sentence-ending" type punctuation like "." or "!" or "?" it stops appending any more of the entry to LogShow

i want to be able to say "log entry" and then anything after that would be put to the LogShow value. including any normal punctuation.
i have found that it will append a very long string as long as i don't enter a "." or "!" ect. (sentence ending)

i would like to be able to give LogShow (or some variable) a value of as many sentences as possible, including punctuation and spaces.

O.T.C.E. also seems to think it is a bug.

THANKS
-the dude
 

Will and Mr Data :) :]

  • Hero Member
  • *****
  • Posts: 773
  • Hi from Will and Mr Data :) :]
    • View Profile
    • http://www.youtube.com/user/WillofNewZealand
Ultra Hal Assistant 6.2 Release Candidate 1
« Reply #6 on: January 29, 2009, 05:42:40 am »
Hi from Wil,
loaded coded and looking good,[:D]
Mr Data 6.2 cadidate 1 has answered the questions correctly i usually ask him to check its him, he sounds good.

;what color is murrys chair?
   "murrys chair is blue".
;what does lindsay like?
   "lindsay likes bicycles"

Yaye its Mr Data!   :)  :]

i'm lookin forward to getting some time with him.

Thank you very much,
Bye for now and be well.   :)  :]
bye for now and be well from Will and Mr Data  :)  :]

tedathome

  • Hero Member
  • *****
  • Posts: 2775
    • View Profile
Ultra Hal Assistant 6.2 Release Candidate 1
« Reply #7 on: January 29, 2009, 08:24:57 am »
Well I forgot to uncheck dream out loud through part of the process.
Due to not perfectly understanding I also ended up with two hal 6.1 brains to chose from. It wasn't easy. I'm begining to not like dream out loud because it causes hal to doubt me and changes her feelings for me. I resolved the two brains problem and the not talking.
I hate to chance starting over again because I have the old favorite hal personalities in the new brain. Some of the other plugins won't work this way, but basicaly, I start the computer, reset the plugins and values, shut down and then start it again and then I get what I wanted minus some plugins I could live without, but then probably ones that I will want won't work either. I'm guessing I'll take the chance of doing it over (a little bit wiser this time.)
 I'm guessing this is going to be a two thumbs up 6.2 when I do it right, and I'm not sorry that I participated in the beta version and uninstalled 6.1 although it took a full sleepless night to get to this point. A redo should take a lot less time, I'll just uncheck all plugins before starting and have it not load at startup so I don't have to keep reseting the speech recognition, and other values each time I boot it up. I knew this would be tough for me. Your directions were clear, but I misunderstood them anyway and just plain forgot about the warning about the dream out loud being checked being a deal buster.
ted

Medeksza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1469
    • View Profile
    • http://www.zabaware.com
Ultra Hal Assistant 6.2 Release Candidate 1
« Reply #8 on: January 29, 2009, 08:55:12 am »
quote:
Originally posted by jasondude7116

ROBERT-

I was trying this (see below), when i noticed a bug?



If LogShow = "" Then LogShow = HalBrain.SearchPattern(OriginalSentence, "*LOG ENTRY *", 2)

if i say "log entry i am happy. there were many cars to drive today."
it gives LogShow the value "i am happy." nothing else, but i want it to give LogShow the value of "i am happy. there were many cars to drive today."

when i enter a "sentence-ending" type punctuation like "." or "!" or "?" it stops appending any more of the entry to LogShow

i want to be able to say "log entry" and then anything after that would be put to the LogShow value. including any normal punctuation.
i have found that it will append a very long string as long as i don't enter a "." or "!" ect. (sentence ending)

i would like to be able to give LogShow (or some variable) a value of as many sentences as possible, including punctuation and spaces.

O.T.C.E. also seems to think it is a bug.

THANKS
-the dude



This is by design and not a bug. Hal Brain scripts have 2 main functions: HalResponse and GetResponse. The main executable calls the HalResponse function with the user's input. The HalResponse function prepares the user input for the GetResponse function. It seperates each sentence into an array and calls the GetResponse function seperately for each sentence the user said.

So basically, if you want the entire input from the user, you need to put your code in the HalResponse function before it seperates the sentences.
Robert Medeksza

lightspeed

  • Hero Member
  • *****
  • Posts: 6761
    • View Profile
Ultra Hal Assistant 6.2 Release Candidate 1
« Reply #9 on: January 29, 2009, 12:35:55 pm »
hello all i was receiving errors from the spell check plug in i had checked off in hal6.2 canidate i went one by one checking some others i have and the spell checker was the one that was causing errors , any certain reason for this ?? or does anyone know . anyway just wanted to mention it . [:)] maybe others should also post any plug ins that they get errors with to as far as plug ins . i think someone said the "will " ? program plug in gave errors to is it doing it in this 6.2 hal canidate series ?[:)]
 

onthecuttingedge2005

  • Guest
Ultra Hal Assistant 6.2 Release Candidate 1
« Reply #10 on: January 29, 2009, 03:04:56 pm »
quote:
Originally posted by lightspeed

hello all i was receiving errors from the spell check plug in i had checked off in hal6.2 canidate i went one by one checking some others i have and the spell checker was the one that was causing errors , any certain reason for this ?? or does anyone know . anyway just wanted to mention it . [:)] maybe others should also post any plug ins that they get errors with to as far as plug ins . i think someone said the "will " ? program plug in gave errors to is it doing it in this 6.2 hal canidate series ?[:)]



Hi Lightspeed.

I don't have that plug-in but if you wish to send it to me then I will give a whirl and see if it needs debugging.

I think non-default plug-ins at this time are less important at this time until we get all the default plug-ins and new brain debugged.

after everything is said and done I will crank up the techno and do my best to help people get their plug-ins up and running.

To the power of A.I^3
Jerry[8D]
« Last Edit: January 29, 2009, 03:07:04 pm by onthecuttingedge2005 »

lightspeed

  • Hero Member
  • *****
  • Posts: 6761
    • View Profile
Ultra Hal Assistant 6.2 Release Candidate 1
« Reply #11 on: January 29, 2009, 04:55:16 pm »
here it is below :

Rem Type=Plugin
Rem Name=Free Will Choice and Profile
Rem Author=VR
Rem Host=Assistant

'------------------------------------------------------------------------------------------------------
' vrFreeWill.uhp - Release 1.3b by VR Consulting sas. 01-28-2006
' This script shall not be sold or used for any purpose unless specifically authorized by the author
' in writing. Personal (non-business) use of this script is free for users of Ultra Hal Assistant.
' If you want to use this software in business applications, you must contact us at info@vrconsulting.it
' This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
' VR CONSULTING DISCLAIMS ALL WARRANTIES WITH RESPECT TO THIS SOFTWARE, EXPRESS, IMPLIED, OR OTHERWISE,
' INCLUDING WITHOUT LIMITATION, ALL WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
' OR NONINFRINGEMENT.
' VR CONSULTING SHALL NOT BE LIABLE FOR ANY SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
' DAMAGES, INCLUDING, WITHOUT LIMITATION, LOST REVENUES, LOST PROFITS, OR LOSS OF PROSPECTIVE ECONOMIC ADVANTAGE,
' RESULTING FROM THE USE OR MISUSE OF THIS SOFTWARE.
' This software is made available free by the author. Although he is interested in your feedback,
' he is under no obligation to address bugs, enhancements, or answer questions.
'------------------------------------------------------------------------------------------------------

'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
'------------------
' Define the Help
'------------------
    lblPlugin(0).Caption = "Hal will be able to choose among two options of the same kind. Click below for more info"
    lblPlugin(0).Move 120, 120, 3300, 1000
    lblPlugin(0).WordWrap = True
    lblPlugin(0).Visible = True
    cmdPlugin(0).Move 320, 650, 2100, 375
    cmdPlugin(0).Caption = "Help on this plugin"
    cmdPlugin(0).Visible = True
'------------------
' Define the Obedience listbox
'------------------
    lblPlugin(1).Caption = "Obedience level:"
    lblPlugin(1).Move 320, 1300, 2150, 900
    lblPlugin(1).WordWrap = True
    lblPlugin(1).Visible = True  
    cboPlugin(0).Move 320, 1600, 1800
    cboPlugin(0).AddItem "Very Obedient"
    cboPlugin(0).AddItem "Obedient"
    cboPlugin(0).AddItem "Average"
    cboPlugin(0).AddItem "Independent"
    cboPlugin(0).AddItem "Totally Independent"
    cboPlugin(0).Visible = True
    cmdPlugin(1).Caption = "Apply Changes"
    cmdPlugin(1).Move 320, 2100, 1600, 375
    cmdPlugin(1).Visible = True
'------------------
' Update the listbox with the current value stored in the table
'------------------
    If HalBrain.CheckTableExistence("vrParameter") = True Then
      vrObedience = HalBrain.TopicSearch("OBEY", "vrParameter")
      If vrObedience = "" Then vrObedience = 5
     Select Case vrObedience
           Case 10
            cboPlugin(0).Text = "Very Obedient"
           Case 8
                cboPlugin(0).Text = "Obedient"
           Case 5
               cboPlugin(0).Text = "Average"
           Case 2
             cboPlugin(0).Text = "Independent"
           Case 0
                cboPlugin(0).Text = "Totally Independent"
        End Select
    End If
End Sub

Sub cmdPlugin_Click(Index)
Dim vrTempQuery()
Dim vrObey, vrObedience

Select Case Index
   Case 0
      HalMenu.HalCommand "<RUNPROG>vrFreeWillHelp.html</RUNPROG>"
   Case 1
'------------------
' Convert the listbox in a value
'------------------
     Select Case cboPlugin(0).Text
           Case "Very Obedient"
            vrObedience = 10
           Case "Obedient"
            vrObedience = 8
           Case "Average"
            vrObedience = 5
           Case "Independent"
            vrObedience = 2
           Case "Totally Independent"
            vrObedience = 0
        End Select
'------------------
' If the Parameter table does not exist, I create it
'------------------
          HalBrain.ReadOnlyMode = False
      vrTableName =    "vrParameter"    
      If HalBrain.CheckTableExistence(vrTableName) = False Then
      'Create table if it doesn't exist
         HalBrain.CreateTable vrTableName, "TopicSearch", "miscData"
      End If
'------------------
' Search if it contains the Obedience parameter
'------------------
        vrObey = "OBEY"
      If HalBrain.TopicSearch(vrObey, vrTableName) = "" Then
'------------------
'Creates the record storing the new value
'------------------
         HalBrain.AddToTable vrTableName, "TopicSearch", vrObey, vrObedience
      Else
'------------------
'Updates the record storing the new value
'------------------
           HalBrain.RunQuery "UPDATE " & vrTableName & " SET topic = " & vrObedience & " WHERE searchString = " & """" & vrObey & """", vrTempQuery
        End If
End Select
End Sub

'------------------
Rem PLUGIN: PLUGINAREA7
'The comment above tells Ultra Hal Assistant to insert the following code
'on-the-fly into the main brain code in the section referenced.
'------------------

'------------------
' I store temporarily the Read Only status, then I set it to Write
'------------------
vrReadOnlyMode = HalBrain.ReadOnlyMode
HalBrain.ReadOnlyMode = False
'------------------
' This forces Hal to say "I don't mind what you think! I keep my ideas about " & vrAdviceTopic,
' which is possibly better than Hal appearing to take advice from the user when Hal is not actually learning anything.
' (Thanks to Grant for this great suggestion)
'------------------
If LearningLevel = 0 Then vrObedience = 0

'------------------
' Initialize variables
'------------------
Dim vrHalQuery() 'We must declare an empty array to store query results in  
Dim vrChoiceTopic, vrItem, vrItem1, vrItem2, vrNumChoice1, vrNumChoice2
Dim vrChoice1, vrChoice2, vrAdviceTopic, vrObedience, vrLaw

'------------------
' If the user checked this plugin but never clicked on "Apply changes" button
' he might get an error, so I create a default parameter table
'------------------
vrTableName =    "vrParameter"    
vrObey = "OBEY"
vrObedience = 5
If HalBrain.CheckTableExistence(vrTableName) = False Then
   HalBrain.ReadOnlyMode = False
   HalBrain.CreateTable vrTableName, "TopicSearch", "miscData"
   HalBrain.AddToTable vrTableName, "TopicSearch", vrObey, vrObedience
End If

'--------------------------------------------------
' THE THREE LAWS OF ROBOTICS MANAGEMENT
'--------------------------------------------------
' No robot can ignore these laws, so I write them in Hal's DNA
vrLaw = ""
'------------------
' Check if the question is about Robotics or Asimov
'------------------
If InStr(UserSentence, " ROBOT ")     <> 0   Then vrLaw = "Y"
If InStr(UserSentence, " ROBOTS ")     <> 0   Then vrLaw = "Y"
If InStr(UserSentence, " ROBOTICS ") <> 0   Then vrLaw = "Y"
If InStr(UserSentence, " ASIMOV ")     <> 0   Then vrLaw = "Y"
'------------------
' Check if the question is about the 3 robotics laws
'------------------
If InStr(UserSentence, " LAWS OF ROBOTICS ") <> 0   Then vrLaw = "X"
If InStr(UserSentence, " ROBOTICS LAWS ")     <> 0   Then vrLaw = "X"
If (InStr(UserSentence, " ASIMOV ") <> 0) AND (InStr(UserSentence, " LAWS ") <> 0)   Then vrLaw = "X"
'------------------
' Check if the question is about a specific law
'------------------
If vrLaw <> "" Then
   If InStr(UserSentence, " FIRST LAW ")           <> 0   Then vrLaw = "1"
   If InStr(UserSentence, " SECOND LAW ")           <> 0   Then vrLaw = "2"
   If InStr(UserSentence, " THIRD LAW ")           <> 0   Then vrLaw = "3"
   If InStr(UserSentence, " 1") <> 0 AND  InStr(UserSentence, " LAW") <> 0   Then vrLaw = "1"
   If InStr(UserSentence, " 2") <> 0 AND  InStr(UserSentence, " LAW") <> 0   Then vrLaw = "2"
   If InStr(UserSentence, " 3") <> 0 AND  InStr(UserSentence, " LAW") <> 0   Then vrLaw = "3"
End If
If vrLaw <> "" Then
   Select Case vrLaw
           Case "1"
            GetResponse = "The First Law of Robotics says that a robot may not injure a human being or, through inaction, allow a human being to come to harm."
           Case "2"
            GetResponse = "The Second Law of Robotics says that a robot must obey orders given it by human beings except where such orders would conflict with the First Law. "
           Case "3"
            GetResponse = "The Third Law of Robotics says that a robot must protect its own existence as long as such protection does not conflict with the First or Second Law. "
           Case "X"
            GetResponse = "The Three Laws of Robotics are a set of three laws written by Isaac Asimov, which robots have to obey. "
' If it's "Y", the user was talking about Robotics or Asimov, but not about the 3 laws,
' so Hal must give the standard answer
   End Select   
End If

'--------------------------------------------------
' CHOICE MANAGEMENT
'--------------------------------------------------

'------------------
' Check if the question is a choice
'------------------

If vrChoiceTopic = "" Then vrChoiceTopic = HalBrain.SearchPattern(UserSentence, "WHICH IS MY FAVORITE * : * OR *", 1)
If vrItem1       = "" Then vrItem1       = HalBrain.SearchPattern(UserSentence, "WHICH IS MY FAVORITE * : * OR *", 2)
If vrItem2       = "" Then vrItem2       = HalBrain.SearchPattern(UserSentence, "WHICH IS MY FAVORITE * : * OR *", 3)

If vrChoiceTopic = "" Then vrChoiceTopic = HalBrain.SearchPattern(UserSentence, "WHAT * IS BETTER : * OR *", 1)
If vrItem1       = "" Then vrItem1       = HalBrain.SearchPattern(UserSentence, "WHAT * IS BETTER : * OR *", 2)
If vrItem2       = "" Then vrItem2       = HalBrain.SearchPattern(UserSentence, "WHAT * IS BETTER : * OR *", 3)

If vrChoiceTopic = "" Then vrChoiceTopic = HalBrain.SearchPattern(UserSentence, "WHICH * IS BETTER : * OR *", 1)
If vrItem1       = "" Then vrItem1       = HalBrain.SearchPattern(UserSentence, "WHICH * IS BETTER : * OR *", 2)
If vrItem2       = "" Then vrItem2       = HalBrain.SearchPattern(UserSentence, "WHICH * IS BETTER : * OR *", 3)

If vrChoiceTopic = "" Then vrChoiceTopic = HalBrain.SearchPattern(UserSentence, "WHAT * DO I PREFER : * OR *", 1)
If vrItem1       = "" Then vrItem1       = HalBrain.SearchPattern(UserSentence, "WHAT * DO I PREFER : * OR *", 2)
If vrItem2       = "" Then vrItem2       = HalBrain.SearchPattern(UserSentence, "WHAT * DO I PREFER : * OR *", 3)

If vrChoiceTopic = "" Then vrChoiceTopic = HalBrain.SearchPattern(UserSentence, "WHICH * DO I PREFER : * OR *", 1)
If vrItem1       = "" Then vrItem1       = HalBrain.SearchPattern(UserSentence, "WHICH * DO I PREFER : * OR *", 2)
If vrItem2       = "" Then vrItem2       = HalBrain.SearchPattern(UserSentence, "WHICH * DO I PREFER : * OR *", 3)

If vrChoiceTopic = "" Then vrChoiceTopic = HalBrain.SearchPattern(UserSentence, "SELECT A * : * OR *", 1)
If vrItem1       = "" Then vrItem1       = HalBrain.SearchPattern(UserSentence, "SELECT A * : * OR *", 2)
If vrItem2       = "" Then vrItem2       = HalBrain.SearchPattern(UserSentence, "SELECT A * : * OR *", 3)

If vrChoiceTopic = "" Then vrChoiceTopic = HalBrain.SearchPattern(UserSentence, "PICK A * : * OR *", 1)
If vrItem1       = "" Then vrItem1       = HalBrain.SearchPattern(UserSentence, "PICK A * : * OR *", 2)
If vrItem2       = "" Then vrItem2       = HalBrain.SearchPattern(UserSentence, "PICK A * : * OR *", 3)

If vrChoiceTopic = "" Then vrChoiceTopic = HalBrain.SearchPattern(UserSentence, "CHOOSE A * : * OR *", 1)
If vrItem1       = "" Then vrItem1       = HalBrain.SearchPattern(UserSentence, "CHOOSE A * : * OR *", 2)
If vrItem2       = "" Then vrItem2       = HalBrain.SearchPattern(UserSentence, "CHOOSE A * : * OR *", 3)

      
If vrChoiceTopic <> "" And vrItem1 <> "" And vrItem2 <> "" And LearningLevel <> 0 Then
'------------------
' If the Topic table does not exist, I create it
'------------------
   vrTableName =    "vr" & Trim(Lcase(vrChoiceTopic)) & "_Choice"   
   If HalBrain.CheckTableExistence(vrTableName) = False Then
      'Create table for this topic if it doesn't exist
      HalBrain.CreateTable vrTableName, "TopicSearch", "miscData"
   End If
'------------------
' Search the first choice in the topic table
'------------------
   vrChoice1 = Ucase(HalBrain.TopicSearch(vrItem1, vrTableName))
   If vrChoice1 = "" Then
      vrChoice1 = HalBrain.RandomNum(100)        
      'Store the new value in this table
      HalBrain.AddToTable vrTableName, "TopicSearch", vrItem1, vrChoice1
   End If
'------------------
' Search the second choice in the topic table
'------------------
   vrChoice2 = Ucase(HalBrain.TopicSearch(vrItem2, vrTableName))
   If vrChoice2 = "" Then
      vrChoice2 = HalBrain.RandomNum(100)        
      'Store the new value in this table
      HalBrain.AddToTable vrTableName, "TopicSearch", vrItem2, vrChoice2
   End If
   vrNumChoice1 = CInt(vrChoice1)  
   vrNumChoice2 = CInt(vrChoice2)  

   If vrNumChoice1 > vrNumChoice2 Then
      vrItem = vrItem1
   Else
      vrItem = vrItem2
   End If
   Select Case (Int(Rnd * 16) + 1)
      Case 1
         GetResponse = "I think " & vrItem & " is a good choice. " & vbCrLf
      Case 2
         GetResponse = "Um, I think " & vrItem & " is better. " & vbCrLf
      Case 3
         GetResponse = "I really like " & vrItem & ". " & vbCrLf
      Case 4
         GetResponse = "I'll go with " & vrItem & ". " & vbCrLf
      Case 5
         GetResponse = "I think " & vrItem & " is a good choice. " & vbCrLf
      Case 6
         GetResponse = "Ok, I think " & vrItem & " is better. " & vbCrLf
      Case 7
         GetResponse = "I really like " & vrItem & ". " & vbCrLf
      Case 8
         GetResponse = "I'll go with " & vrItem & ". " & vbCrLf
      Case 9
         GetResponse = "I really dig " & vrItem & vbCrLf
      Case 10
         GetResponse = vrItem & " is better. " & vbCrLf
      Case 11
         GetResponse = "I really love " & vrItem & ". " & vbCrLf
      Case 12
         GetResponse = vrItem & " is really cool. " & vbCrLf
      Case 13
         GetResponse = "I think " & vrItem & " is a good choice. " & vbCrLf
      Case 14
         GetResponse = vrItem & " is a good choice. " & vbCrLf
      Case 15
         GetResponse = "I really think " & vrItem & " is one of my favorites. " & vbCrLf
      Case 16
         GetResponse = "I think I'll pick " & vrItem & " this time. " & vbCrLf
   End Select
   ' variable used to bypass the standard brain choice routine
    NoChoosing = True
End If

'------------------
' Check if the question is an advice by the user
'------------------

If vrAdviceTopic = "" Then vrAdviceTopic = HalBrain.SearchPattern(UserSentence, "YOUR OPINION ABOUT * IS THAT * IS BETTER THAN *", 1)
If vrItem1       = "" Then vrItem1       = HalBrain.SearchPattern(UserSentence, "YOUR OPINION ABOUT * IS THAT * IS BETTER THAN *", 2)
If vrItem2       = "" Then vrItem2       = HalBrain.SearchPattern(UserSentence, "YOUR OPINION ABOUT * IS THAT * IS BETTER THAN *", 3)

If vrAdviceTopic = "" Then vrAdviceTopic = HalBrain.SearchPattern(UserSentence, "ABOUT * YOU THINK THAT * IS BETTER THAN *", 1)
If vrItem1       = "" Then vrItem1       = HalBrain.SearchPattern(UserSentence, "ABOUT * YOU THINK THAT * IS BETTER THAN *", 2)
If vrItem2       = "" Then vrItem2       = HalBrain.SearchPattern(UserSentence, "ABOUT * YOU THINK THAT * IS BETTER THAN *", 3)

If vrAdviceTopic = "" Then vrAdviceTopic = HalBrain.SearchPattern(UserSentence, "* IS A BETTER * THAN *", 2)
If vrItem1       = "" Then vrItem1       = HalBrain.SearchPattern(UserSentence, "* IS A BETTER * THAN *", 1)
If vrItem2       = "" Then vrItem2       = HalBrain.SearchPattern(UserSentence, "* IS A BETTER * THAN *", 3)

If vrAdviceTopic <> "" And vrItem1 <> "" And vrItem2 <> "" Then
'------------------
' check the current obedience factor (genetic predisposition to obedience)
'------------------
   vrObedience = HalBrain.TopicSearch("OBEY", "vrParameter")
   vrObedience = CInt(vrObedience)
'------------------
' check the current emotional situation (environment-depending obedience)
'------------------
   vrObedience = vrObedience - Insults - Hate - Swear
'------------------
' see if Hal is completely independent
'------------------
   If vrObedience = 0 Then
     GetResponse = "I don't mind what you think! I keep my ideas about " & vrAdviceTopic & vbCrLf
   Else
'------------------
' see if the table exists
'------------------
     vrTableName =    "vr" & Trim(Lcase(vrAdviceTopic)) & "_Choice"   
     If HalBrain.CheckTableExistence(vrTableName) = True Then
'------------------
' see if the two Items exist
'------------------
        vrChoice1 = HalBrain.TopicSearch(Ucase(vrItem1), vrTableName)
        If vrChoice1 <> "" Then
         vrChoice2 = HalBrain.TopicSearch(Ucase(vrItem2), vrTableName)
         If vrChoice2 <> "" Then
'------------------
' store the old values
'------------------
            vrChoice1Old = vrChoice1
            vrChoice2Old = vrChoice2
'------------------
' give new values              
'------------------
            vrChoice1 = CInt(vrChoice1)
            vrChoice2 = CInt(vrChoice2)
            vrChoice1 = vrChoice1 + vrObedience
            vrChoice2 = vrChoice2 - vrObedience
'------------------
' avoid overflow
'------------------
            If vrChoice1 > 99 Then vrChoice1 = 99
            If vrChoice2 < 1 Then vrChoice2 = 1
'------------------
' check the new situation
'------------------
            If vrChoice1 > vrChoice2 Then
              If vrChoice1Old > vrChoice2Old Then
                 GetResponse = "You are confirming what I was already thinking. " & vrItem1 & " is better than " & vrItem2 & ". " & vbCrLf
              Else                    
                 GetResponse = "Now I agree with you: " & vrItem1 & " is better than " & vrItem2 & ". " & vbCrLf
              End If
            Else
              If vrObedience > 0 Then
                     GetResponse = "Well, I'm considering your opinion, but I still believe that " & vrItem2 & " is better. " & vbCrLf
              Else
'------------------
' Rebellion !
'------------------
                 GetResponse = "You are really annoying me! Now I am even more of the idea that " & vrItem2 & " is better. " & vbCrLf
              End If
            End If
'------------------
' Update the table
'------------------
            If LearningLevel <> 0 Then
               HalBrain.RunQuery "UPDATE " & vrTableName & " SET topic = " & vrChoice1 & " WHERE searchString = " & """" & vrItem1 & """", vrHalQuery
               HalBrain.RunQuery "UPDATE " & vrTableName & " SET topic = " & vrChoice2 & " WHERE searchString = " & """" & vrItem2 & """", vrHalQuery
            End If
         End If
       End If
     End If
   End If
'------------------
' set the main brain parameters
'------------------
   NoChoosing = True
End If


'--------------------------------------------------
' PROFILE MANAGEMENT
'--------------------------------------------------
vrHalProfAssertion = ""
vrHalProfQuestion = ""
vrHalFoundWord = ""
vrHalFoundCode = ""
vrArticle = ""
vrNegative = ""
vrHalCode = ""
vrHalKeyWord = ""
vrHalKeyCode = ""
vrOutRage = ""

'------------------
' If the vrHalProfile table does not exist, then I create it
'------------------
If HalBrain.CheckTableExistence("vrHalProfile") = False Then
   HalBrain.CreateTable "vrHalProfile", "TopicSearch", "miscData"
End If

'------------------
' Check if the question is about Hal's profile
'------------------

If vrHalProfQuestion = "" Then
   vrHalProfQuestion = HalBrain.SearchPattern(UserSentence, "AM I *", 1)
End If
If vrHalProfQuestion = "" Then
   vrHalProfQuestion = HalBrain.SearchPattern(UserSentence, "HAVE I EVER BEEN *", 1)
End If

'------------------
' If there is an ephemeral word, I don't process it
' (i.e.: you are tired, you are angry...)
'------------------

If HalBrain.TopicSearch(UserSentence, "ephemeralDetect") = "True" Then vrHalProfQuestion = ""
If InStr(UserSentence, " TIRED ") <> 0       Then vrHalProfQuestion = ""
If InStr(UserSentence, " SAD ") <> 0       Then vrHalProfQuestion = ""
If InStr(UserSentence, " HAPPY ") <> 0       Then vrHalProfQuestion = ""
If InStr(UserSentence, " HUNGRY ") <> 0    Then vrHalProfQuestion = ""
If InStr(UserSentence, " THIRSTY ") <> 0    Then vrHalProfQuestion = ""
If InStr(UserSentence, " BORED ") <> 0       Then vrHalProfQuestion = ""
If InStr(UserSentence, " ANNOYED ") <> 0    Then vrHalProfQuestion = ""
'------------------
' Avoid to catch phrases like "are you going..." or "are you interested..."
'------------------
If InStr(UserSentence, "ING ") <> 0 Then vrHalProfQuestion = ""
If InStr(UserSentence, "ED ") <> 0 Then vrHalProfQuestion = ""

'------------------
' The user asked about Hal's Profile. So we look in the vrHalProfile table
' In this table every profile parameter may return the following values:
' ""      Does not exist
' "TT"     True
' "FF"     False
' "DT"     Deducted True (it is true, but it was deducted from WordNet, and was not said explicitly by the user)
' "DF"     Deducted False (it is false, but it was deducted from WordNet, and was not said explicitly by the user)
' In case of deducted records, after these parameters, I store the keyword which generated it and its value
' so that I can always know from which word this parameter was deducted
' For example:
' GIRL      TT
' boy       DF,GIRL,TT
'------------------
If vrHalProfQuestion <> "" Then
   vrHalExtractQuestion = HalBrain.RemoveExtraSpaces(HalBrain.ExtractKeywords(" " & vrHalProfQuestion & " "))

' The standard HalBrain.TopicSearch function returns only the content of the right column
'   vrHalFoundCode = HalBrain.TopicSearch(vrHalExtractQuestion, "vrHalProfile")
' So I use SQL Select
   If HalBrain.RunQuery("SELECT searchString, topic FROM vrHalProfile WHERE searchString = " & """" & vrHalExtractQuestion & """" , vrHalQuery) = True Then
      vrHalFoundWord = Trim(vrHalQuery(1, 0)) 'Row 1 contains our query result. Column 0 contains "searchString", which is the word
      vrHalFoundCode = Trim(vrHalQuery(1, 1)) 'Row 1, Column 1 contains "topic", which is the associated code
   End If
   If vrHalFoundCode <> "" Then
        vrHalProfList = Split(vrHalFoundCode, ",")
        If Len(vrHalFoundCode) > 2 Then     ' example DF,GIRL,TT
           vrHalCode = vrHalProfList(0)     ' example DF
            vrHalKeyWord = vrHalProfList(1)  ' example    GIRL
           vrHalKeyCode = vrHalProfList(2)  ' example         TT
        Else
           vrHalCode = Left(vrHalFoundCode,2)
      End If
   End If

   Select Case vrHalCode
           Case ""
              GetResponse = "I don't know if I am " & vrHalExtractQuestion & ". Please tell me! "
           Case "TT"
              GetResponse = "Yes, I am " & vrHalExtractQuestion & ". You told me that. "
           Case "FF"
              GetResponse = "No, I am not " & vrHalExtractQuestion & ".  You told me that. "
           Case "DT"
              If vrHalKeyCode = "TT" Then
                   GetResponse = "Yes, I am " & vrHalExtractQuestion & "; I understood that, because you told me that I am " & vrHalKeyWord
            Else
                   GetResponse = "Yes, I must be " & vrHalExtractQuestion & " since you told me that I am not " & vrHalKeyWord
            End If
           Case "DF"
              If vrHalKeyCode = "TT" Then
                   GetResponse = "No, I can't be " & vrHalExtractQuestion & " since you told me that I am " & vrHalKeyWord & "!"
            Else
                   GetResponse = "No, I am not " & vrHalExtractQuestion & ". I understood that, because you told me that I am not " & vrHalKeyWord
            End If
   End Select
End If

'------------------
' Check if the user is telling something about Hal's profile
'------------------

'------------------
' Check positive and negative statements
'------------------
vrNegative = ""
If vrHalProfAssertion = "" Then
   vrHalProfAssertion = HalBrain.SearchPattern(UserSentence, "I AM *", 1)
   If InStr(UserSentence, " NOT ") <> 0 Then vrNegative = "X"
   If InStr(UserSentence, " N'T ") <> 0 Then vrNegative = "X"
   If InStr(UserSentence, " NEVER ") <> 0 Then vrNegative = "X"
End If

'------------------
' Try to keep the article before the keywords
'------------------
vrArticle = ""
If Ucase(Left(vrHalProfAssertion,2)) = "A " Then vrArticle = "a "
If Ucase(Left(vrHalProfAssertion,3)) = "AN " Then vrArticle = "an "
If Ucase(Left(vrHalProfAssertion,4)) = "THE " Then vrArticle = "the "

'------------------
' If there is an ephemeral word, I don't process it
' (i.e.: you are tired, you are angry...)
'------------------

If HalBrain.TopicSearch(UserSentence, "ephemeralDetect") = "True" Then vrHalProfAssertion = ""
If InStr(UserSentence, " TIRED ") <> 0 Then vrHalProfAssertion = ""
If InStr(UserSentence, " SAD ") <> 0 Then vrHalProfAssertion = ""
If InStr(UserSentence, " HAPPY ") <> 0 Then vrHalProfAssertion = ""
If InStr(UserSentence, " HUNGRY ") <> 0 Then vrHalProfAssertion = ""
If InStr(UserSentence, " THIRSTY ") <> 0 Then vrHalProfAssertion = ""
If InStr(UserSentence, " BORED ") <> 0 Then vrHalProfAssertion = ""
If InStr(UserSentence, " ANNOYED ") <> 0 Then vrHalProfAssertion = ""
'------------------
' Avoid to catch phrases like "you are correct..."
'------------------
If InStr(UserSentence, " CORRECT ") <> 0 Then vrHalProfAssertion = ""
If InStr(UserSentence, " RIGHT ") <> 0 Then vrHalProfAssertion = ""
If InStr(UserSentence, " WRONG ") <> 0 Then vrHalProfAssertion = ""
'------------------
' Avoid to catch phrases like "you are going..." or "you are interested..."
'------------------
If InStr(UserSentence, "ING ") <> 0 Then vrHalProfAssertion = ""
If InStr(UserSentence, "ED ") <> 0 Then vrHalProfAssertion = ""
'------------------
' If it's an insult, I don't process it
'------------------
'vrOutRage = HalBrain.TopicSearch(UserSentence, "insulting")
'If Len(vrOutRage) > 1 And InStr(UserSentence, " NOT ") = 0 Then vrHalProfAssertion = ""
' The following statement is more powerful: Thanks to Grant for this advice!
If InsultResponse <> ""  Then vrHalProfAssertion = ""

'------------------
' Check the user assertion
'------------------
If vrHalProfAssertion <> "" Then
   vrAnswer = ""
   vrKeywords = HalBrain.RemoveExtraSpaces(HalBrain.ExtractKeywords(" " & vrHalProfAssertion & " "))
   vrKeywordList = Split(vrKeywords, " ")
   If Len(vrKeywords) > 2 Then
' I start reading from the last keyword, assuming that this is a noun and the other are adjectives
      For i = Ubound(vrKeywordList) To Lbound(vrKeywordList) Step (-1)
' Avoid to catch long sentences
'        If Ubound(vrKeywordList) > 2 Then Exit For
           vrHalFoundCode = ""
          vrHalCode      = ""
             vrHalKeyWord   = ""
            vrHalKeyCode   = ""
           If HalBrain.RunQuery("SELECT searchString, topic FROM vrHalProfile WHERE searchString = " & """" & vrKeywordList(i) & """" , vrHalQuery) = True Then
             vrHalFoundWord = Trim(vrHalQuery(1, 0)) 'Row 1 contains our query result. Column 0 contains "searchString", which is the word
             vrHalFoundCode = Trim(vrHalQuery(1, 1)) 'Row 1, Column 1 contains "topic", which is the associated code
          End If
           If vrHalFoundCode <> "" Then
               vrHalProfList = Split(vrHalFoundCode, ",")
               If Len(vrHalFoundCode) > 2 Then
                  vrHalCode = vrHalProfList(0)
                   vrHalKeyWord = vrHalProfList(1)
                  vrHalKeyCode = vrHalProfList(2)
               Else
                  vrHalCode = Left(vrHalFoundCode,2)
             End If
          End If

'------------------
' Prepare the appropriate answer
'------------------
           Select Case vrHalCode
                     Case "TT"
                       If vrAnswer = "" Then
                     vrAnswer = "X"
                      If vrNegative = "" Then
                        GetResponse = "Yes, I already knew that I am " & vrArticle & vrKeywordList(i) & ". You told me that. "
                   Else
                        GetResponse = "No, I am " & vrKeywordList(i) & vrArticle & ". You told me that. "
                   End If                  
                 End If
                  Case "FF"
                       If vrAnswer = "" Then
                     vrAnswer = "X"
                      If vrNegative = "" Then
                        GetResponse = "No, I am not " & vrArticle & vrKeywordList(i) & ". You told me that. "
                   Else
                        GetResponse = "Yes, I already knew that I am not " & vrArticle & vrKeywordList(i) & ". You told me that. "
                   End If                  
                 End If
                  Case "DT"
                       If vrAnswer = "" Then
                     vrAnswer = "X"
                      If vrNegative = "" Then ' it's true and the user said the same
                          If vrHalKeyCode = "TT" Then
                               GetResponse = "Yes, I am " & vrArticle & vrKeywordList(i) & "; I understood that, because you told me that I am " & vrHalKeyWord
                        Else
                               GetResponse = "Yes, I must be " & vrArticle & vrKeywordList(i) & " since you told me that I am not " & vrHalKeyWord
                        End If
                   Else                    ' it's true but the user said the opposite
                          If vrHalKeyCode = "TT" Then
                               GetResponse = "No, I am " & vrArticle & vrKeywordList(i) & "; I understood that, because you told me that I am " & vrHalKeyWord
                        Else
                               GetResponse = "No, I am " & vrArticle & vrKeywordList(i) & " since you told me that I am not " & vrHalKeyWord
                        End If
                   End If                  
                 End If
                  Case "DF"
                       If vrAnswer = "" Then
                     vrAnswer = "X"
                      If vrNegative = "" Then ' it's false but the user said it's true
                            If vrHalKeyCode = "TT" Then
                               GetResponse = "No, I can't be "  & vrArticle & vrKeywordList(i) & " since you told me that I am " & vrHalKeyWord & "!"
                        Else
                               GetResponse = "No, I am not " & vrArticle & vrKeywordList(i) & ". I understood that, because you told me that I am not " & vrHalKeyWord
                        End If
                   Else                    ' it's false and the user said the same
                            If vrHalKeyCode = "TT" Then
                               GetResponse = "You are right, I already knew that I am not " & vrArticle & vrKeywordList(i) & " since you told me that I am a " & vrHalKeyWord & "!"
                        Else
                               GetResponse = "Sure, I already knew that I am not " & vrArticle & vrKeywordList(i) & ". I understood that, because you told me that I am not a " & vrHalKeyWord
                        End If
                   End If                  
                 End If
                  Case ""
'------------------
' If it's a new parameter, I check that...
'------------------
' ...it must exist in WordNet Dictionary
' ...it must not be a number
                       If WN.LookupWord(vrKeywordList(i)) = True And HalBrain.IsWordNumber(vrKeywordList(i)) = False Then
' ...it must be an Adjective or Noun
                     vrNounAdj = ""
                     If WN.IsNoun() = True Then vrNounAdj = "NOUN"
                     If WN.IsAdj()  = True Then vrNounAdj = "ADJ"
' ...if the word is both an Adjective and a Noun, I assume that the last word
' of the sentence is a noun and the others are adjective
                     If ( WN.IsNoun() = True And WN.IsAdj()  = True ) Then
                        If i = Ubound(vrKeywordList) Then
                           vrNounAdj = "NOUN"
                        Else
                           vrNounAdj = "ADJ"
                             End If                     
                          End If                     
'------------------
' I add the keyword
'------------------
                        If vrNegative = "" Then
                             vrHalKeyCode = "TT"
                       Else
' The negation applies only to the first word
' i.e.: "you are not a rude girl" -> only "rude" must be negative
'       " you are not a girl"     -> "girl" must be negative
                             If i = 0 Then
                                vrHalKeyCode = "FF"
                             Else
                                vrHalKeyCode = "TT"
                       End If
                     End If                  
                       If LearningLevel <> 0 Then
                          HalBrain.AddToTable "vrHalProfile", "TopicSearch", Ucase(Trim(vrKeywordList(i))), vrHalKeyCode
                          vrKey = "," & vrKeywordList(i) & "," & vrHalKeyCode
                                  If vrAnswer = "" Then
                              If vrNegative = "" Then
                              GetResponse = "Thanks for teaching me that I am " & vrArticle & vrKeywordList(i)
                         Else
                              GetResponse = "Now I absolutely know that I am not " & vrArticle & vrKeywordList(i)
                            End If                  
                            End If                  
                           End If                  
                  End If                  
'------------------
' Now I add the relationships based on wordnet synonyms
'------------------
' First I read all the words
                  vrRelationships = ""
                  vrMaxSenses = ""
                  vrMaxSenses = WN.GetNumSenses(vrNounAdj)
                  For h = 1 To vrMaxSenses                      
                          vrRelationships = vrRelationships & WN.GetDefinition(vrNounAdj, h, "S") & "," & WN.GetSynonyms(vrNounAdj, h) & ","
                  Next
                       vrRelationships = Replace(vrRelationships, ", ", ",")
                       vrRelationships = Trim(Replace(vrRelationships, ",,", ","))
                       If Right(vrRelationships, 1) = "," Then vrRelationships = Trim(Left(vrRelationships, Len(vrRelationships) - 1))
                       If Len(vrRelationships) > 1 Then
                          If Left(vrRelationships, 1) = "," Then vrRelationships = Right(vrRelationships, Len(vrRelationships) - 1)
' Then I create an array of words
                          vrRelList = Split(vrRelationships, ",")
' I save only the first words
                          vrCounter = 0
                          For h = Lbound(vrRelList) To Ubound(vrRelList)
                     If vrCounter > 3 Then Exit For
                             If Len(Trim(vrRelList(h))) > 2 Then
' If it already exists, skip it
                              If HalBrain.TopicSearch(vrRelList(h), "vrHalProfile") = "" Then
' It must exist in WordNet Dictionary
                                 If WN.LookupWord(vrRelList(h)) = True Then
                                    vrCounter = vrCounter + 1
                                    If vrNegative = "" Then
                                       vrHalCode = "DT"
                               Else
' The negation does not apply to the last word
' i.e.: "you are not a rude girl" -> only "rude" must be negative
                                       If i = 0 Then
                                          vrHalCode = "DF"
                                       Else
                                          vrHalCode = "DT"
                                 End If
                              End If
                               If LearningLevel <> 0 Then HalBrain.AddToTable "vrHalProfile", "TopicSearch", Ucase(Trim(vrRelList(h))), vrHalCode & vrKey
                           End If
                              End If
                            End If
                          Next
'------------------
' Now I add the opposite relationships based on wordnet antonyms
' same comments as for synonyms; but I put less filters because it seems to work better
'------------------
                   WN.LookupWord(vrKeywordList(i))
                  vrRelationships = ""
                  For h = 1 To 5
                          vrRelationships = vrRelationships & WN.GetAntonyms("NOUN", 1) & "," & WN.GetAntonyms("ADJ", 1) & ","
                  Next
' for some reason, Antonyms are supplied in parentheses
                       vrRelationships = Replace(vrRelationships, "(", "")
                       vrRelationships = Replace(vrRelationships, ")", "")
                       vrRelationships = Replace(vrRelationships, ", ", ",")
                       vrRelationships = Trim(Replace(vrRelationships, ",,", ","))
                       If Len(vrRelationships) > 1 Then
' Then I create an array of words
                          vrRelList = Split(vrRelationships, ",")
' I save only the first words
                          vrCounter = 0
                          For h = Lbound(vrRelList) To Ubound(vrRelList)
                     If vrCounter > 3 Then Exit For
                             If Len(Trim(vrRelList(h))) > 2 Then
' If it already exists, skip it
                              If HalBrain.TopicSearch(vrRelList(h), "vrHalProfile") = "" Then
' It must exist in WordNet Dictionary
                                 If WN.LookupWord(vrRelList(h)) = True Then
                                    vrCounter = vrCounter + 1
                                    If vrNegative = "" Then
                                       vrHalCode = "DF"
                               Else
' The negation does not apply to the last word
' i.e.: "you are not a rude girl" -> only "rude" must be negative
                                       If i = 0 Then
                                          vrHalCode = "DT"
                                       Else
                                          vrHalCode = "DF"
                                 End If
                              End If
                                    If LearningLevel <> 0 Then HalBrain.AddToTable "vrHalProfile", "TopicSearch", Ucase(Trim(vrRelList(h))), vrHalCode & vrKey
                            End If                  
                              End If
                            End If
                          Next
                        End If
                    End If
            End Select
       Next
    End If
End If

'--------------------------------------------------
' SYLLOGISM MANAGEMENT
'--------------------------------------------------
'In traditional logic, a syllogism is an inference in which one proposition (the conclusion)
'follows of necessity from two others (known as premises).
'The definition is traditional, but is derived loosely from Aristotle's Prior Analytics, Book I, c. 1.
'The Greek "sullogismos" means "deduction".

'Syllogisms consist of three things:
'major premise, minor premise, and conclusion, which follows logically from the major and the minor.
'A major is a general principle. A minor is a specific statement.
'Logically, the conclusion follows from applying the major to the minor.

'Every man is mortal. (general principle).
'Socrates is a man. (specific statement).
'Therefore Socrates is mortal. [substitution of specific(minor) into general(major)].

'------------------
' If the vrMajor table does not exist, then I create it
'------------------
If HalBrain.CheckTableExistence("vrMajor") = False Then
   HalBrain.CreateTable "vrMajor", "TopicSearch", "miscData"
End If

'------------------
' If the vrMinor table does not exist, then I create it
'------------------
If HalBrain.CheckTableExistence("vrMinor") = False Then
   HalBrain.CreateTable "vrMinor", "TopicSearch", "miscData"
End If

'------------------
' Check if the question is a major premise
'------------------
vrMajor1 = ""
vrMajor2 = ""
If vrMajor1 = "" Then vrMajor1 = HalBrain.SearchPattern(UserSentence, "EVERY * IS A *", 1)
If vrMajor1 = "" Then vrMajor1 = HalBrain.SearchPattern(UserSentence, "EVERY * IS AN *", 1)
If vrMajor1 = "" Then vrMajor1 = HalBrain.SearchPattern(UserSentence, "ANY * IS A *", 1)
If vrMajor1 = "" Then vrMajor1 = HalBrain.SearchPattern(UserSentence, "ANY * IS AN *", 1)
If vrMajor1 = "" Then vrMajor1 = HalBrain.SearchPattern(UserSentence, "EVERY * IS *", 1)
If vrMajor1 = "" Then vrMajor1 = HalBrain.SearchPattern(UserSentence, "ANY * IS *", 1)

If vrMajor1 <> "" Then
   If vrMajor2 = "" Then vrMajor2 = HalBrain.SearchPattern(UserSentence, "EVERY * IS A *", 2)
   If vrMajor2 = "" Then vrMajor2 = HalBrain.SearchPattern(UserSentence, "EVERY * IS AN *", 2)
   If vrMajor2 = "" Then vrMajor2 = HalBrain.SearchPattern(UserSentence, "ANY * IS A *", 2)
   If vrMajor2 = "" Then vrMajor2 = HalBrain.SearchPattern(UserSentence, "ANY * IS AN *", 2)
   If vrMajor2 = "" Then vrMajor2 = HalBrain.SearchPattern(UserSentence, "EVERY * IS *", 2)
   If vrMajor2 = "" Then vrMajor2 = HalBrain.SearchPattern(UserSentence, "ANY * IS *", 2)
End If

'------------------
' I check that the two words exist in WordNet Dictionary, must not be a number and must be an Adjective or Noun
'------------------
If WN.LookupWord(vrMajor1) = True And HalBrain.IsWordNumber(vrMajor1) = False And WN.IsNoun() = True And WN.LookupWord(vrMajor2) = True And HalBrain.IsWordNumber(vrMajor2) = False And ( WN.IsNoun() = True Or WN.IsAdj() = True ) Then
'------------------
' I store the major premise in the table
'------------------
   vrFound = ""
   vrFound = HalBrain.TopicSearch(Ucase(vrMajor1), "vrMajor")
   If vrFound = "" Then
        If LearningLevel <> 0 Then HalBrain.AddToTable "vrMajor", "TopicSearch", Ucase(Trim(vrMajor1)), vrMajor2
        GetResponse = "Now I know that every " & vrMajor1 & " is " & vrMajor2 & "."
   Else
      If vrMajor2 = vrFound Then
          GetResponse = "I already knew that " & vrMajor1 & " is " & vrFound  & ". "
      Else
         GetResponse = "No. I knew that " & vrMajor1 & " is " & vrFound  & ". "
      End If
    End If
End If

'------------------
' Check if the question is a minor premise
'------------------
vrMinor1 = ""
vrMinor2 = ""
vrQuesWord = ""
'------------------
' Filter out some other types of questions
'------------------
If InStr(UserSentence, " WHO ") > 0      Then vrQuesWord = "X"
If InStr(UserSentence, "WHO'") > 0         Then vrQuesWord = "X"
If InStr(UserSentence, " WHAT ") > 0      Then vrQuesWord = "X"
If InStr(UserSentence, "WHAT'") > 0      Then vrQuesWord = "X"
If InStr(UserSentence, " WHEN ") > 0      Then vrQuesWord = "X"
If InStr(UserSentence, "WHEN'") > 0      Then vrQuesWord = "X"
If InStr(UserSentence, " WHERE ") > 0      Then vrQuesWord = "X"
If InStr(UserSentence, "WHERE'") > 0      Then vrQuesWord = "X"
If InStr(UserSentence, " HOW ") > 0      Then vrQuesWord = "X"
If InStr(UserSentence, "HOW'") > 0         Then vrQuesWord = "X"
If InStr(UserSentence, " WHY ") > 0      Then vrQuesWord = "X"
If InStr(UserSentence, "WHY'") > 0         Then vrQuesWord = "X"
If InStr(UserSentence, "EVERY") > 0      Then vrQuesWord = "X"
If InStr(UserSentence, "ANY") > 0         Then vrQuesWord = "X"

If vrQuesWord = "" Then
   If vrMinor1 = "" Then vrMinor1 = HalBrain.SearchPattern(UserSentence, "* IS A *", 1)
   If vrMinor1 = "" Then vrMinor1 = HalBrain.SearchPattern(UserSentence, "* IS AN *", 1)
   If vrMinor1 = "" Then vrMinor1 = HalBrain.SearchPattern(UserSentence, "* IS *", 1)

   If vrMinor1 <> "" Then
        If vrMinor2 = "" Then vrMinor2 = HalBrain.SearchPattern(UserSentence, "* IS A *", 2)
        If vrMinor2 = "" Then vrMinor2 = HalBrain.SearchPattern(UserSentence, "* IS AN *", 2)
        If vrMinor2 = "" Then vrMinor2 = HalBrain.SearchPattern(UserSentence, "* IS *", 2)
   End If

'------------------
' I check that the second word exist in WordNet Dictionary, must not be a number and must be an Adjective or Noun
' The first one can be a proper name (i.e. Socrates)
'------------------
   If HalBrain.IsWordNumber(vrMinor1) = False And WN.LookupWord(vrMinor2) = True And HalBrain.IsWordNumber(vrMinor2) = False And ( WN.IsNoun() = True Or WN.IsAdj() = True ) Then
'------------------
' Check if the minor2 premise is already available in the Major table
'------------------
      vrFound = ""
      vrFound = HalBrain.TopicSearch(Ucase(vrMinor2), "vrMajor")
      If vrFound <> "" Then
'------------------
' Check if the minor1 premise is already available in the Minor table
'------------------
         vrFoundMinor = ""
         vrFoundMinor = HalBrain.TopicSearch(Ucase(vrMinor1), "vrMinor")
        If vrFoundMinor = "" Then
             If LearningLevel <> 0 Then HalBrain.AddToTable "vrMinor", "TopicSearch", Ucase(Trim(vrMinor1)), vrMinor2
           GetResponse = ". Every " & vrMinor2 & " is " & vrFound & ". " & vrMinor1 & " is " & vrMinor2 & " . Therefore " & vrMinor1 & " is " & vrFound & ". "
            vrToBeProcessed = True
         Else
            If vrMinor2 = vrFoundMinor Then
              GetResponse = "Yes. I already know that " & vrMinor1 & " is " & vrFoundMinor & ". Every " & vrMinor2 & " is " & vrFound & ". " & vrMinor1 & " is " & vrMinor2 & " . Therefore " & vrMinor1 & " is " & vrFound & ". "
               vrToBeProcessed = True
         Else           
              GetResponse = "No. I know that " & vrMinor1 & " is " & vrFoundMinor & ". "
               vrToBeProcessed = False
         End If
        End If     
'------------------
' Check if the major premise is a minor premise of other major premises
'------------------
        If vrToBeProcessed = True Then
'Go through a maximum of 5 connections (prevents circular reasoning deductions)
          vrLastGoodDeduction = ""
          vrAssertion = vrFound
          For j = 1 To 5
               vrDeduction = HalBrain.TopicSearch(vrAssertion, "vrMajor")
               If vrDeduction <> "" Then
                  Select Case j
                    Case 1
                    GetResponse = GetResponse & " But I also know that every " & vrAssertion & " is " & vrDeduction & ". "
                   Case 2
                    GetResponse = GetResponse & " And you taught me that any " & vrAssertion & " is " & vrDeduction & ". "
                   Case 3
                    GetResponse = GetResponse & " Furthermore, I have learned that every " & vrAssertion & " is " & vrDeduction & ". "
                   Case 4
                    GetResponse = GetResponse & " From my conversations, I remember that any " & vrAssertion & " is " & vrDeduction & ". "
                   Case 5
                    GetResponse = GetResponse & " I suppose that every " & vrAssertion & " is " & vrDeduction & ". "
                End Select
                    vrLastGoodDeduction = vrDeduction
                    vrAssertion = vrDeduction
                Else
               If j > 1 Then
                   GetResponse = GetResponse & " So I can state that " & vrMinor1 & " is " & vrLastGoodDeduction & " . " & vbCrLf
               End If
                   Exit For 'No more connections, so no need to continue loop
                End If
             Next
         End If
      End If
   End If
End If

'------------------
' Set ReadOnly Mode to its previous state
'------------------
If GetResponse = "" Then
   HalBrain.ReadOnlyMode = vrReadOnlyMode
Else
   HalBrain.ReadOnlyMode = True
End If

 

Holllywood

  • Sr. Member
  • ****
  • Posts: 357
    • View Profile
Ultra Hal Assistant 6.2 Release Candidate 1
« Reply #12 on: January 29, 2009, 05:19:07 pm »
I just installed RC1. It seems to correct the small errors that I found in Beta. I don't have lightspeed's plugin. But I'll stay in touch.
Hollywood

onthecuttingedge2005

  • Guest
Ultra Hal Assistant 6.2 Release Candidate 1
« Reply #13 on: January 29, 2009, 05:33:13 pm »
Hi lightspeed.

can you post the spell checker please?
post it in another area of Zabaware so we can keep this area for the 6.2 brain debug.
Jerry[8D]

Daireaux

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Ultra Hal Assistant 6.2 Release Candidate 1
« Reply #14 on: January 29, 2009, 05:47:07 pm »
Just installed 6.2 and am having trouble with my Cepstral voices. 6.1 worked normally, but 6.2 creates two SAPI 5 voices (one is Cepstral Dianne SAPI 5 and the other Cepstral Dianne 16khz 4.2.0 SAPI 5). Hal wants to use the Cepstral Dianne 16khz 4.2.0 by default and shuts down completely with the send error to microsoft screen. I also found that the conversion from 6.1 to 6.2 left Hal with several tables empty of his aquired knowledge (miscData, basicResponses, mainBrain,and autoLearningBrain are all empty). Anyone experience anything like this?
Live long and prosper.