'For the record.
'Project D.A.V.I.D
'Dynamically Advanced Virtual Intelligent Droid.
Copy and paste the code into a text file then save as SomeFileName.uhp into your Ultra Hal Assistant 6 folder then choose the plugin via HAL's brain options panel.
'This is D.A.V.I.D's True Statement turing plug-in.
'This plug-in looks for and saves high quality true statements that are used for answering Questions, Confimations, Yes, No, Maybe are concluded under true statement rules.
'there are no random responses in this plug-in, when the plug-in chooses to say yes it chooses a select true statement to finish the answer to the question in query.
'I have put many off time hours into this plug-in and tested it a billion times, it works...
'Learning examples:
'User: Snow is cold and wet and sometimes soggy.
'HAL: Hal may give a response on its own here.
'User: Is snow cold?
'HAL: Yes, Snow is cold and wet and sometimes soggy.
this is just a single true statement and is not limited to just one statement about snow in confirmation.
This Plug-in was designed for the purpose of answering questions a Turing Judge may ask the bot, if the bot knows the answer then it will give the answer.
User: Fire is not cold. '<-- True Statement.
HAL: will respond with it's own selected response.
User: Is fire cold?
HAL: No, Fire is not cold.
Last updated 11_05_17, Obsolete.
download uhp file for current plug-in
'Rem Type=Plugin
'Rem Name=Turing Plugin 11_06_17
'Rem Author=Gerald L. Blakley A.K.A OnTheCuttingEdge2005
'Rem Host=Assistant
'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
lblPlugin(0).Caption = "This is the True statements turing plug-in, it learns true statements and uses them to answer questions."
lblPlugin(0).Move 120, 10, 3300, 1000
lblPlugin(0).WordWrap = True
lblPlugin(0).Visible = True
End Sub
Rem PLUGIN: PLUGINAREA7
'The preceding comment is actually a plug-in directive for
'the Ultra Hal host application. It allows for code snippets
'to be inserted here on-the-fly based on user configuration.
'Last Patch 11_05_17
'D.A.V.I.D.S TRUE STATEMENTS & GENERAL REASONING PLUG-IN.
'BY: ONTHECUTTINGEDGE.
'LETS CREATE A BLOCK SAVE IF NEEDED.
If BlockSave = True Then HalBrain.ReadOnlyMode = True
If BlockSave = False Then HalBrain.ReadOnlyMode = False
ProNouns = "False"
If InStr(UserSentence, " WHO ") > 0 Then ProNouns = "True"
If InStr(UserSentence, " WHAT ") > 0 Then ProNouns = "True"
If InStr(UserSentence, " WHEN ") > 0 Then ProNouns = "True"
If InStr(UserSentence, " WHERE ") > 0 Then ProNouns = "True"
If InStr(UserSentence, " WHY ") > 0 Then ProNouns = "True"
If InStr(UserSentence, " HOW ") > 0 Then ProNouns = "True"
'LEAVE IT, THERE'S SOME GOOD STUFF IN THERE.
'If InStr(UserSentence, " THAT ") > 0 Then ProNouns = "True"
'If InStr(UserSentence, " IT ") > 0 Then ProNouns = "True"
'PREVENT A QUESTION FROM BEING SAVED HERE.
'If InStr(UserSentence, " WHICH ") > 0 Then ProNouns = "True"
'LETS BLOCK SAVE IF PRONOUNS ARE FOUND
If ProNouns = "True" Then BlockSave = True
'LETS MAKE SURE THE STRING IS CLEANED UP FOR SEARCHING PURPOSES.
TempUserSent = HalBrain.AlphaNumericalOnly(OriginalSentence)
TempUserSent = " " & Ucase(TempUserSent) & " "
TempUserSent = Replace(TempUserSent, " ", " ", 1, - 1, vbTextCompare)
'LETS SEE IF OPERATORS ARE PRESENT.
'ALL MY CODE MUST BE IN ORDER. LEAVE IT
If TempUserSent <> "" Then
Operators = "False"
If InStr(1, TempUserSent, " IS ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " OR ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " AND ", vbTextCompare) > 0 Then Operators = "True"
'EXCLUSIVE & FAVORED WORDS. HIGH QUALITY TRUE STATEMENTS.
If InStr(1, TempUserSent, " AT ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " NOT ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " IN ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " ON ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " BUT ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " IF ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " THEN ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " ARE ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " CAN ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " HAVE ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " WAS ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " WILL ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " WENT ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " GET ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " GETS ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " HAS ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " DO ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " CAUSE ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " CAUSED ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " CAUSES ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " WOULD ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " COULD ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " TO ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " TOO ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " ALSO ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " LIKE ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " THE ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " SOMETIMES ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " BECAUSE ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " TRUE ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " FALSE ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " EQUALS ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " EQUAL ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " FAVORITES ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " FAVORITE ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " LOVED ", vbTextCompare) > 0 Then Operators = "True"
If InStr(1, TempUserSent, " LOVE ", vbTextCompare) > 0 Then Operators = "True"
End If
'RESTRICT PERSONAL INFORMATION FROM BEING SAVED HERE, BRAIN SCRIPT HAS ITS OWN CODE FOR THAT.
'If InStr(1, TempUserSent, " I ", vbTextCompare) > 0 Then BlockSave = True
'If InStr(1, TempUserSent, " YOU ", vbTextCompare) > 0 Then BlockSave = True
'If InStr(1, TempUserSent, " YOUR ", vbTextCompare) > 0 Then BlockSave = True
'If InStr(1, TempUserSent, " MY ", vbTextCompare) > 0 Then BlockSave = True
If InStr(1, TempUserSent, " ME ", vbTextCompare) > 0 Then BlockSave = True
If InStr(1, TempUserSent, " THEY ", vbTextCompare) > 0 Then BlockSave = True
If InStr(1, TempUserSent, " THEIR ", vbTextCompare) > 0 Then BlockSave = True
If InStr(1, TempUserSent, " WE ", vbTextCompare) > 0 Then BlockSave = True
If InStr(1, TempUserSent, " NAME ", vbTextCompare) > 0 Then BlockSave = True
If InStr(1, TempUserSent, " HE ", vbTextCompare) > 0 Then BlockSave = True
If InStr(1, TempUserSent, " SHE ", vbTextCompare) > 0 Then BlockSave = True
'If InStr(1, TempUserSent, " THEM ", vbTextCompare) > 0 Then BlockSave = True
'BLOCK SAVE IF A QUESTION IS ASKED HERE.
If InStr(1, OriginalSentence, "?", vbTextCompare) > 0 Then BlockSave = True
'TEST THE SENTENCE FOR OPERATOR NONE PRONOUN QUESTIONS.
TestTempUserSent = "<START>" & TempUserSent & "<END>"
'REMOVE EXTRA SPACES.
TestTempUserSent = Replace(TestTempUserSent, " ", " ", 1, - 1, vbTextCompare)
'LETS REMOVE LEADING AND TRAILING SPACES FOR TESTING.
TestTempUserSent = Replace(TestTempUserSent, "<START> ", "<START>", 1, - 1, vbTextCompare)
TestTempUserSent = Replace(TestTempUserSent, " <END>", "<END>", 1, - 1, vbTextCompare)
'LETS SEE IF THE OPERATOR IS A QUESTION WHICH MEANS IT'S LEADING THE SENTENCE.
OperQuestion = "False"
If InStr(1, TestTempUserSent, "<START>IS ", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, "<START>OR ", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, "<START>AND ", vbTextCompare) > 0 Then OperQuestion = "True"
'EXCLUSIVE
If InStr(1, TestTempUserSent, "<START>ARE ", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, "<START>CAN ", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, "<START>HAVE ", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, "<START>WAS ", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, "<START>WILL ", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, "<START>WHICH ", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, "<START>DO ", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, "<START>DOES ", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, " IS<END>", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, " OR<END>", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, " AND<END>", vbTextCompare) > 0 Then OperQuestion = "True"
'EXCLUSIVE
If InStr(1, TestTempUserSent, " ARE<END>", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, " CAN<END>", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, " HAVE<END>", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, " WAS<END>", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, " WILL<END>", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, " WHICH<END>", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, " DO<END>", vbTextCompare) > 0 Then OperQuestion = "True"
If InStr(1, TestTempUserSent, " DOES<END>", vbTextCompare) > 0 Then OperQuestion = "True"
PatchWhat = GetResponse
TestTempHalSent = Replace(TestTempHalSent, "<username>", "<Line:2359>", 1, - 1, vbTextCompare)
TestTempHalSent = "<START>" & PatchWhat & "<END>"
'REMOVE EXTRA SPACES.
TestTempHalSent = Replace(TestTempHalSent, " ", " ", 1, - 1, vbTextCompare)
'LETS REMOVE LEADING AND TRAILING SPACES FOR TESTING.
TestTempHalSent = Replace(TestTempHalSent, "<START> ", "<START>", 1, - 1, vbTextCompare)
TestTempHalSent = Replace(TestTempHalSent, " <END>", "<END>", 1, - 1, vbTextCompare)
'LETS SEE IF THE OPERATOR IS A QUESTION WHICH MEANS IT'S LEADING OR TRAILING THE SENTENCE.
PatchHalQuestions = "False"
If InStr(1, TestTempHalSent, "<START>IS ", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, "<START>OR ", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, "<START>AND ", vbTextCompare) > 0 Then PatchHalQuestions = "True"
'EXCLUSIVE
If InStr(1, TestTempHalSent, "<START>ARE ", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, "<START>CAN ", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, "<START>HAVE ", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, "<START>WAS ", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, "<START>WILL ", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, "<START>WHICH ", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, "<START>DO ", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, "<START>DOES ", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, " IS<END>", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, " OR<END>", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, " AND<END>", vbTextCompare) > 0 Then PatchHalQuestions = "True"
'EXCLUSIVE
If InStr(1, TestTempHalSent, " ARE<END>", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, " CAN<END>", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, " HAVE<END>", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, " WAS<END>", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, " WILL<END>", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, " WHICH<END>", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, " DO<END>", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, " DOES<END>", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, " ME<END>", vbTextCompare) > 0 Then PatchHalQuestions = "True"
If InStr(1, TestTempHalSent, "<START>ME<END>", vbTextCompare) > 0 Then PatchHalQuestions = "True"
AlreadyQuestion = "False"
FixGetResponse = HalBrain.AlphaNumericalOnly(GetResponse)
FixGetResponse = Replace(FixGetResponse, " NOMORE ", "", 1, - 1, vbTextCompare)
If InStr(1, TestTempHalSent, "?<END>", vbTextCompare) > 0 Then AlreadyQuestion = "True"
If Len(FixGetResponse) > 0 And PatchHalQuestions = "True" And AlreadyQuestion = "False" Then GetResponse = FixGetResponse & "? " & vbCrLf
If TempUserSent <> "" Then
If HalBrain.CheckTableExistence("General_Reasoning") = False Then
'CREATE TABLE FOR THIS PLUGIN IF IT DOESN'T EXIST.
HalBrain.CreateTable "General_Reasoning", "Brain", "autoLearningBrain"
End If
End If
'AVOID THE GREETINGS TRAP WHERE A USER CAN REPEAT GREETINGS AND THE BOT WILL KEEP GREETING.
'THIS ROUTINE PREVENTS HAL FROM FALLING INTO THAT TRAP, HAL WILL KNOW IF YOU ALREADY GREETED IT
'AND RESPOND ACCOURDINGLY.
If HalBrain.TopicSearch(TempUserSent, "helloDetect") = "True" And PrevSent <> "" Then GetResponse = " You already said hello " & UserName & ". "
If HalBrain.TopicSearch(TempUserSent, "helloDetect") = "True" And HalBrain.TopicSearch(PrevUserSent, "helloDetect") = "True" And PrevSent <> "" Then GetResponse = UserName & ", If you continue with the greetings I will not talk to you. "
'ONTHECUTTINGEDGE.
If ProNouns = "False" And OperQuestion = "False" And Operators = "True" And Len(TempUserSent) > 11 Then
'THIS SCRIPT IS AN EXAMPLE OF SCANNING FOR DUPLICATE STRINGS.
'TEST STRING 01.
PreRec01 = TempUserSent 'OUR CONTROL STRING.
'REMOVE PUNCTUATIONS.
PreRec01 = HalBrain.AlphaNumericalOnly(PreRec01)
'REMOVE MULTIPLE SPACES THAT CAN RESULT IN A FAILED COMPARE.
PreRec01 = Replace(PreRec01, " ", " ", 1, - 1, vbTextCompare)
PreRec02 = HalBrain.QABrain(TempUserSent, "General_Reasoning", UserBrainRel)
PreRec02 = HalBrain.AlphaNumericalOnly(PreRec02)
PreRec02 = Replace(PreRec02, " ", " ", 1, - 1, vbTextCompare)
If PreRec01 = PreRec02 Then SameRecord = True
HalBrain.DebugWatch SameRecord, "SameRecord"
If SameRecord = True Then
GetResponse = GetResponse & vbCrLf
Else
HalBrain.AddToTable "General_Reasoning", "Brain", TempUserSent, TempUserSent
'YOU CAN CHOOSE ANOTHER ROUTINE HERE.
GetResponse = GetResponse & vbCrLf
'END ANY OTHER ROUTINES AFTER THIS FUNCTION COMPLETES.
HalBrain.ReadOnlyMode = True
Exit Function
'GOODBYE.
'GOD BLESS.
End If
End If
'RESET BLOCKSAVE TO FALSE AFTER THIS SCRIPT SO OTHER SCRIPTS CAN SAVE FOR THEIR APPENDING.
BlockSave = False
'LETS MAKE OUR OWN GENERAL RESPONSE AND TRIGGER IT USING OUR ARRAY
UserBrainRel = 0
If Len(TempUserSent) > 10 And Operators = "True" Then
KeywordList = Split(TempUserSent, " ")
'LETS PLUG IN OUR RESPONSE TABLE AND LET IT GROW WITH KNOWLEDGE.
HalUserXBrain = HalBrain.QABrain(TempUserSent, "General_Reasoning", UserBrainRel)
For i = Lbound(KeywordList) To Ubound(KeywordList)
TopicXTable = KeywordList(i)
If TopicXTable <> "" Then Exit For
Next
RealCheck = "False"
IsQuestion = "False"
SubjectIsGood = "False"
PrevCurrentSubject = WN.FindFirstNoun(PrevUserSent, True)
If Len(PrevCurrentSubject) > 2 Then SubjectIsGood = "True"
If InStr(1, TempUserSent, TopicXTable, vbTextCompare) > 0 Then RealCheck = "True"
If InStr(1, OriginalSentence, "?", vbTextCompare) > 0 Then IsQuestion = "True"
If InStr(1, UserSentence, " THAT ", vbTextCompare) > 0 And SubjectIsGood = "True" Then UserSentence = Replace(UserSentence, " THAT ", " " & PrevCurrentSubject & " ", 1, -1, vbTextCompare)
If InStr(1, UserSentence, " IT ", vbTextCompare) > 0 And SubjectIsGood = "True" Then UserSentence = Replace(UserSentence, " IT ", " " & PrevCurrentSubject & " ", 1, -1, vbTextCompare)
HalBrain.DebugWatch PrevCurrentSubject, "PrevCurrentSubject"
HalBrain.DebugWatch UserSentence, "UserSentence IT & THAT to Subject"
'CONFIRMATION ROUTINE PLACED IN ANSWER OF A USER'S QUESTION, YES/NO/MAYBE
Confirmation = "MAYBE, "
If HalUserXBrain <> "" And OperQuestion = "True" And RealCheck = "True" Or InStr(1, HalUserXBrain, " MAYBE ", vbTextCompare) > 0 Then Confirmation = "MAYBE, "
If HalUserXBrain <> "" And OperQuestion = "True" And RealCheck = "True" Or InStr(1, HalUserXBrain, " TRUE ", vbTextCompare) > 0 Then Confirmation = "YES, "
If HalUserXBrain <> "" And OperQuestion = "True" And RealCheck = "True" And InStr(1, HalUserXBrain, " NOT ", vbTextCompare) > 0 Or InStr(1, HalUserXBrain, " NO ", vbTextCompare) > 0 Or InStr(1, HalUserXBrain, " FALSE ", vbTextCompare) > 0 Then Confirmation = "NO, "
'SEE IF HAL IS BEING ASKED A KNOWN QUESTION FROM A TRUE STATEMENT, IF SO RESPOND TO IT.
If HalUserXBrain <> "" And RealCheck = "True" And OperQuestion = "True" And Confirmation <> "" Then
GetResponse = "" & Confirmation & HalUserXBrain & ". " & ""
ElseIf HalUserXBrain <> "" And RealCheck = "True" And ProNouns = "True" And OperQuestion = "True" Then
GetResponse = "" & HalUserXBrain & ". " & ""
ElseIf HalUserXBrain <> "" And RealCheck = "True" And IsQuestion = "True" Then
GetResponse = "" & HalUserXBrain & ". " & ""
End If
Exit Function
End If
'_____________________________________________________________________________________________________________
TagToReplace = Lcase("<username>")
If InStr(1, GetResponse, TagToReplace, vbTextCompare) > 0 Then
GetResponse = Replace(GetResponse, TagToReplace, UserName, 1, - 1, vbTextCompare)
End If
'LOOK FOR ROGUE TAGS AND REMOVE THEM.
RogueTags = HalBrain.SearchPattern(GetResponse, "*<*>", 2)
GetResponse = Replace(GetResponse, RogueTags, "", 1, - 1, vbTextCompare)
GetResponse = Replace(GetResponse, "<>", "", 1, - 1, vbTextCompare)
HalBrain.DebugWatch RogueTags, "#RogueTags" & RogueTags
Just Plug and Play...
Have A Nice Day!
Jerry