Zabaware Support Forums
Zabaware Forums => Programming using the Ultra Hal Brain Editor => Topic started by: Larry on August 23, 2003, 08:08:16 pm
-
This seems to pick up other things as well... but the file is of a managable size... So what is it??? Well, my bot gives off the wall generic answers to personal questions - next time it gets these questions, I can go into PersonalQuestions.brn and edit the answers the bot will give the next time it gets that question. If it finds an answer, it won't keep adding to the file...
'Will you please just answer the question?
OpenQuest = False
If InStr(1, UserSentence, " WHAT ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHERE ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHY ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHO ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHEN ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " HOW ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " TELL YOU ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " TELL ME ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " TO KNOW ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " TO HEAR ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " TO LEARN ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " FIND OUT ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " AM I ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " FAVORITE ", 1) > 0 Then OpenQuest = False
If OpenQuest = True Then
If InStr(1, UserSentence, " MY ", 1) > 0 Or InStr(1, UserSentence, " AM I ", 1) > 0 Then AboutMy = True
If OpenQuest = True And AboutMy = True Then
HalUserBrain = HalBrain.QABrain(UserSentence, WorkingDir & "PersonalQuestions" & ".brn", UserBrainRel)
Pass = False
If HalBrain.CheckRepetition(HalUserBrain, UserSentence) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevSent) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevUserSent) = True Then Pass = True
If Pass = False then
If UserBrainRel > 75 Then
'found an answer
GetResponse = GetResponse & HalUserBrain & vbCrLf
BlockSave = True
Else
'save the question since it can't find an answer we'll just fix it manually later
AnswerSent = "@" & OriginalSentence
QuestionSent = " " & Trim(HalBrain.ExtractKeywords(UserSentence))
If HalBrain.CountInstances(" ", QuestionSent) > 2 Then HalBrain.AppendFile WorkingDir & "PersonalQuestions" & ".brn", AnswerSent & vbCrLf & QuestionSent
UserBrainRel = 0
End If
End If
End If
End If
BTW - you probably should create PersonalQuestions.brn... I've heard if it don't exist, it will be created automatically, but I don't know.
-
Bug fixes :
'Will you please just answer the question?
AboutMy = False
If InStr(1, UserSentence, " MY ", 1) > 0 Or InStr(1, UserSentence, " I ", 1) > 0 Then AboutMy = True
If AboutMy = True then
OpenQuest = False
If InStr(1, UserSentence, " DO I ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHAT ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHERE ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHY ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHO ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHEN ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " HOW ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " FAVORITE ", 1) > 0 Then OpenQuest = False
If OpenQuest = True And AboutMy = True Then
HalUserBrain = HalBrain.QABrain(UserSentence, WorkingDir & "PersonalQuestions" & ".brn", UserBrainRel)
Pass = False
If HalBrain.CheckRepetition(HalUserBrain, UserSentence) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevSent) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevUserSent) = True Then Pass = True
If Pass = False then
If UserBrainRel > 0 Then
DebugInfo = DebugInfo & "Will you please just answer the question?: " & vbCrLf
DebugInfo = DebugInfo & GetResponse & vbCrLf
DebugInfo = DebugInfo & UserBrainRel & vbCrLf
End If
If UserBrainRel > 75 Then
'found an answer
GetResponse = GetResponse & HalUserBrain & vbCrLf
GetResponse = HalBrain.HalFormat(GetResponse)
BlockSave = True
DebugInfo = DebugInfo & "Will you please just answer the question?: " & vbCrLf
DebugInfo = DebugInfo & GetResponse & vbCrLf
DebugInfo = DebugInfo & UserBrainRel & vbCrLf
Else
'save the question since it can't find an answer we'll just fix it manually later
AnswerSent = "@" & OriginalSentence
QuestionSent = " " & Trim(HalBrain.ExtractKeywords(UserSentence)) & " "
If HalBrain.CountInstances(" ", QuestionSent) > 1 Then
HalBrain.AppendFile WorkingDir & "PersonalQuestions" & ".brn", AnswerSent & vbCrLf & QuestionSent
End If
UserBrainRel = 0
DebugInfo = DebugInfo & "Will you please just answer the question?: " & vbCrLf
DebugInfo = DebugInfo & "Saving new question " & vbCrLf
DebugInfo = DebugInfo & AnswerSent & vbCrLf
DebugInfo = DebugInfo & QuestionSent & vbCrLf
BlockSave = True
End If
End If
End If
End If
-
Hey Larry,
Neat-o! Great job on this piece of the puzzle -I also think alot about Hal's
vagueness issue. Here try this: Delete PersonalQuestions out of the folder
then ask Ashlee181818 a question she don't know. Ok, now look in the folder!
CatAtomic >B)
-
Larry great job!
I have one question, were you deliberately excluding "favorites" from the personal question file? You set this line below "false" if the question dealt with favorites:
If InStr(1, UserSentence, " FAVORITE ", 1) > 0 Then OpenQuest = False
I've changed it to true so I can include favorite items in the file. I'm keeping an eye out for false entries in the file. Curious if it was intentional or an oversight.
Again, great job thanks!
Glenn
-
You oughtta save the unanswered question into a different file.
That way you don't gotta go diggin' for it. I'm gonna set up Dee Dee
so she can tell you what questions she couldn't get and then put them
in the PersonalQuestions.brn.
CatA >B)
-
I'm seeing a small problem with this approach. Not all personal information in the file will be retrieved and used. For example, if you type in "what is your birthday" an entry is made "@what is your birthday" & "MY BIRTHDAY" if you edit the question with your desired response and again ask "what is your birthday" hal will not use the response in the file, but will write another entry. The key words "MY BIRTHDAY" are not sufficient for hal to use the response. But if you type "what day is your birthday" the keywords " DAY MY BIRTHDAY" are created and if the same question is asked again, the desired response will be used this time.
This requires some deep thought and a bottle of scotch...[:p]
-
Hummm... Well, Favorites I did leave out on purpose since it's dealt with later in the script... I keep getting a lot of questions that are not really personal, so I've narrowed it down even more...
As for saving the questions in a different file... well, my thought was, even if Hal doesn't have a custom answer to that question, if asked again, at least Hal can ask the question back to the user... at least until I edit the file and change that question...
As far as when is your birthday... I hadn't really run into that problem yet - I'm still running into other problems...
Here's the latest fix ...
'Will you please just answer the question?
AboutMy = False
OpenQuest = False
If InStr(1, UserSentence, " ABOUT MY ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " ARE MY ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " BE MY ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " IN MY ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " IS MY ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " ON MY ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " AM I ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " DO I ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " AM I IN ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " AM I A ", 1) > 0 Then OpenQuest = True
If AboutMy = True then
If InStr(1, UserSentence, " DO ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHAT ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHERE ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHICH ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHY ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHO ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHEN ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " HOW ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHAT DO I CALL IT WHEN ", 1) > 0 Then OpenQuest = False
If InStr(1, UserSentence, " FAVORITE ", 1) > 0 Then OpenQuest = False
If InStr(1, UserSentence, " THINK ", 1) > 0 Then OpenQuest = False
If InStr(1, UserSentence, " WEATHER ", 1) > 0 Then OpenQuest = False
If InStr(1, UserSentence, " SPORTS ", 1) > 0 Then OpenQuest = False
If OpenQuest = True And AboutMy = True Then
HalUserBrain = HalBrain.QABrain(UserSentence, WorkingDir & "PersonalQuestions" & ".brn", UserBrainRel)
Pass = False
If HalBrain.CheckRepetition(HalUserBrain, UserSentence) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevSent) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevUserSent) = True Then Pass = True
If Pass = False then
If UserBrainRel > 0 Then
DebugInfo = DebugInfo & "Will you please just answer the question?: " & vbCrLf
DebugInfo = DebugInfo & UserBrainRel & vbCrLf
End If
If UserBrainRel > 75 Then
'found an answer
GetResponse = GetResponse & HalUserBrain & vbCrLf
GetResponse = HalBrain.HalFormat(GetResponse)
BlockSave = True
DebugInfo = DebugInfo & "Will you please just answer the question?: " & vbCrLf
DebugInfo = DebugInfo & GetResponse & vbCrLf
DebugInfo = DebugInfo & UserBrainRel & vbCrLf
Else
'save the question since it can't find an answer we'll just fix it manually later
AnswerSent = "@" & OriginalSentence
QuestionSent = " " & Trim(HalBrain.ExtractKeywords(UserSentence)) & " "
If HalBrain.CountInstances(" ", QuestionSent) > 1 And BlockSave = False Then
HalBrain.AppendFile WorkingDir & "PersonalQuestions" & ".brn", AnswerSent & vbCrLf & QuestionSent
End If
UserBrainRel = 0
DebugInfo = DebugInfo & "Will you please just answer the question?: " & vbCrLf
DebugInfo = DebugInfo & "Saving new question: " & vbCrLf
DebugInfo = DebugInfo & AnswerSent & vbCrLf
DebugInfo = DebugInfo & QuestionSent & vbCrLf
DebugInfo = DebugInfo & GetResponse & vbCrLf
BlockSave = True
End If
End If
End If
End If
-
Hey Larry,
Nice job, how long did it take you to figure that one out?[8D]
-
That bottle of scotch was good Ahhhh.....[:p]
Ok Larry, I took your last fixed version, expanded just slightly the acceptable parameters (for my own needs) and added a forced keyword in order for phrases like "when is your birthday" to be recognized and matched. I used the forced keyword "PERSONAL" it is appended to the end of every UserSentence before it goes to keyword parsing and saving. So far all the questions that I had that were not being recongnized are now working.
I did note one observaton, if you have for example the phrase "where were you born" and What place were you born" the keywords respectively are "BORN PERSONAL" and "PLACE BORN PERSONAL" if the latter question is located higher up in the .brn file that the first question, the first will never be identified and the correct response given. The phrase with the keywords "BORN PERSONAL" MUST be located in the brain file before the "PLACE BORN PERSONAL"
FINAL NOTE AND WARNING: If you choose to use the patch below, you must either manually edit every keyword and append "PERSONAL" to the end of every keyword line, or you will have to redo all your questions and responses.
enjoy
Glenn
'Will you please just answer the question?
AboutMy = False
OpenQuest = False
If InStr(1, UserSentence, " ABOUT MY ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " ARE MY ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " BE MY ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " IN MY ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " IS MY ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " ON MY ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " AM I ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " WAS I ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " WERE I ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " DO I ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " AM I IN ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " AM I A ", 1) > 0 Then OpenQuest = True
If AboutMy = True Then
If InStr(1, UserSentence, " DO ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHAT ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHERE ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHICH ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHY ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHO ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHEN ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " HOW ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHAT DO I CALL IT WHEN ", 1) > 0 Then OpenQuest = False
If InStr(1, UserSentence, " FAVORITE ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " THINK ", 1) > 0 Then OpenQuest = False
If InStr(1, UserSentence, " WEATHER ", 1) > 0 Then OpenQuest = False
If InStr(1, UserSentence, " SPORTS ", 1) > 0 Then OpenQuest = False
If OpenQuest = True And AboutMy = True Then
UserSentencep = UserSentence & " PERSONAL"
HalUserBrain = HalBrain.QABrain(UserSentencep, WorkingDir & "PersonalQuestions" & ".brn", UserBrainRel)
Pass = False
If HalBrain.CheckRepetition(HalUserBrain, UserSentence) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevSent) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevUserSent) = True Then Pass = True
If Pass = False Then
If UserBrainRel > 0 Then
DebugInfo = DebugInfo & "Will you please just answer the question?: " & vbCrLf
DebugInfo = DebugInfo & UserBrainRel & vbCrLf
End If
If UserBrainRel > 75 Then
'found an answer
GetResponse = GetResponse & HalUserBrain & vbCrLf
GetResponse = HalBrain.HalFormat(GetResponse)
BlockSave = True
DebugInfo = DebugInfo & "Will you please just answer the question?: " & vbCrLf
DebugInfo = DebugInfo & GetResponse & vbCrLf
DebugInfo = DebugInfo & UserBrainRel & vbCrLf
Else
'save the question since it can't find an answer we'll just fix it manually later
AnswerSent = "@" & OriginalSentence
UserSentences = UserSentence & " PERSONAL"
QuestionSent = " " & Trim(HalBrain.ExtractKeywords(UserSentences)) & " "
If HalBrain.CountInstances(" ", QuestionSent) > 1 And BlockSave = False Then
HalBrain.AppendFile WorkingDir & "PersonalQuestions" & ".brn", AnswerSent & vbCrLf & QuestionSent
End If
UserBrainRel = 0
DebugInfo = DebugInfo & "Will you please just answer the question?: " & vbCrLf
DebugInfo = DebugInfo & "Saving new question: " & vbCrLf
DebugInfo = DebugInfo & AnswerSent & vbCrLf
DebugInfo = DebugInfo & QuestionSent & vbCrLf
DebugInfo = DebugInfo & GetResponse & vbCrLf
BlockSave = True
End If
End If
End If
End If
-
Lol... I actually had a fix for that, that might be a bit easier than what you did... I changed this line -> If UserBrainRel > 75 Then, then those short ones like you mentioned went through... but like every thing else, I found other bugs... I won't say that I've given up... but I've re-done that section AGAIN... I won't post it because now it has new bugs... lol
No wonder the Hal makers don't post updates...
-
Say, all you guys could help me out a bit... aim Ashlee181818 and ask her any personal questions you can think of... everything would be logged, so this would help me figure out what happened... or happening with my logic... lol Thanks, guys!!!
-
quote:
Originally posted by Larry
Lol... I actually had a fix for that, that might be a bit easier than what you did... I changed this line -> If UserBrainRel > 75 Then, then those short ones like you mentioned went through... but like every thing else, I found other bugs... I won't say that I've given up... but I've re-done that section AGAIN... I won't post it because now it has new bugs... lol
No wonder the Hal makers don't post updates...
That line was in the code I was using and it did not help the "short ones" from not matching. That was the reason I added the forced keyword. Did you change it to a higher or lower value. I didn't think about it at the time but I bet this line is the reason hal has trouble finding "where were you born" if it doesn't come before "what place were you born" the match parameters are too loose at 75.
-
Well at 75, it required more of a match... where as 50, it allowed 'close' matches... however, now you're talking 'where' versas 'when' - those two words don't make it in the keyword line at all... I was actually thinking of changeing that line to just put the whole question in as key words... don't really know how that would work, but it would seem to me that the more words to compare to, the better the match would be...
Tell you what, lets just change that line and see what happens...
I didn't think I would do any more posting of this plugin until I got all the bugs worked out, but here it is any ways...
'Will you please just answer the question?
AboutMy = False
OpenQuest = False
If InStr(1, UserSentence, " ABOUT MY ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " ARE MY ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " BE MY ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " IN MY ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " IS MY ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " ON MY ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " AM I ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " DO I ", 1) > 0 Then AboutMy = True
If InStr(1, UserSentence, " AM I IN ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " AM I A ", 1) > 0 Then OpenQuest = True
If AboutMy = True then
If InStr(1, UserSentence, " DO ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHAT ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHERE ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHICH ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHY ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHO ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHEN ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " HOW ", 1) > 0 Then OpenQuest = True
If InStr(1, UserSentence, " WHEN ARE YOU CONVINCED ", 1) > 0 Then OpenQuest = False
If InStr(1, UserSentence, " DO YOU BELIEVE ", 1) > 0 Then OpenQuest = False
If InStr(1, UserSentence, " DO YOU SUPPOSE ", 1) > 0 Then OpenQuest = False
If InStr(1, UserSentence, " WHAT DO I CALL IT WHEN ", 1) > 0 Then OpenQuest = False
If InStr(1, UserSentence, " FAVORITE ", 1) > 0 Then OpenQuest = False
If InStr(1, UserSentence, " THINK ", 1) > 0 Then OpenQuest = False
If InStr(1, UserSentence, " WEATHER ", 1) > 0 Then OpenQuest = False
If InStr(1, UserSentence, " SPORTS ", 1) > 0 Then OpenQuest = False
If OpenQuest = True And AboutMy = True Then
HalUserBrain = HalBrain.QABrain(UserSentence, WorkingDir & "PersonalQuestions" & ".brn", UserBrainRel)
Pass = False
If HalBrain.CheckRepetition(HalUserBrain, UserSentence) = True Or HalBrain.CheckRepetition(HalUserBrain,
PrevSent) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevUserSent) = True Then Pass = True
If Pass = False then
If UserBrainRel > 0 And UserBrainRel < 61 Then
DebugInfo = DebugInfo & "Will you please just answer the question?: " & vbCrLf
DebugInfo = DebugInfo & GetResponse & vbCrLf
DebugInfo = DebugInfo & UserBrainRel & vbCrLf
End If
If UserBrainRel > 60 Then
'found an answer
GetResponse = HalUserBrain & vbCrLf
GetResponse = HalBrain.HalFormat(GetResponse)
BlockSave = True
DebugInfo = DebugInfo & "Will you please just answer the question?: " & vbCrLf
DebugInfo = DebugInfo & GetResponse & vbCrLf
DebugInfo = DebugInfo & UserBrainRel & vbCrLf
If UserBrainRel > HighestRel Then
HighestRel = UserBrainRel
HighestRelResponse = GetResponse
End If
Score = UserBrainRel + 1
Hurdle = GainControl + 20
Else
'save the question since it can't find an answer we'll just fix it manually later
AnswerSent = "@" & Trim(OriginalSentence)
QuestionSent = " " & Trim(UserSentence)
If HalBrain.CountInstances(" ", QuestionSent) > 2 And BlockSave = False Then
HalBrain.AppendFile WorkingDir & "PersonalQuestions" & ".brn", AnswerSent & vbCrLf & QuestionSent
HalBrain.AppendFile WorkingDir & "PersonalQuestions4U" & ".brn", AnswerSent & vbCrLf & QuestionSent
'This is new from the last, due to another post... and I actually used the idea - anyone wanting to know how I used it - email me...
End If
UserBrainRel = 0
DebugInfo = DebugInfo & "Will you please just answer the question?: " & vbCrLf
DebugInfo = DebugInfo & "Saving new question: " & vbCrLf
DebugInfo = DebugInfo & AnswerSent & vbCrLf
DebugInfo = DebugInfo & QuestionSent & vbCrLf
DebugInfo = DebugInfo & GetResponse & vbCrLf
BlockSave = True
End If
End If
End If
End If