72
« on: September 01, 2003, 05:43:53 pm »
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