This is the 2_Deep demo plug-in.
this plug-in utilizes more advanced deductive reasoning ability besides the usual IF & Then Statements. it parses out operator words and uses them to parse out sentences in special ways.
it is best to use a lot who, what, when, where, why, how, that, type sentences so that HAL will begin extracting those specific words for the operators that HAL will need to parse sentences.
this plug-in also has word entanglement structuring, by saying things like:
Is means should be.
or
Is means would be.
this will teach HAL that those words are intertwined and can be interchanged when saving deductive sentences, like:
User: A cat is a mammal.
HAL: A cat is also a feline.
User: A cat is what?
HAL: A cat should be a mammal.
User: A cat is also what?
HAL: A cat is a feline.
this plug-in works just like the If-Then deductive script in HAL except it uses more advanced deductive entanglement. the entanglement is only 2-Deep in word ply for this demo version.
a lot of the new reasoning will become automated as HAL learns words to parse with.
I usually teach HAL these specific words by saying things like:
What Then?
Why would we do that?
How is that?
When are we going?
and so on.
HAL will start picking up on words that follow, Who, What, When, Where, Why, How, That. after that HAL will begin finding new words
from those words and begin using them as parsers.
don't forget about teaching entangled words to HAL because this will increase the deductive factor quite a bit.
Rem Type=Plugin
Rem Name=2 Deep
Rem Author=Gerald L. Blakley A.K.A OnTheCuttingEdge2005
Rem Host=All
'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
lblPlugin(0).Caption = "2-Deep Sentence Operators with entanglement reasoning, REASONING AND LEARNING PROGRAM"
lblPlugin(0).Move 120, 10, 3300, 1000
lblPlugin(0).WordWrap = True
lblPlugin(0).Visible = True
End Sub
Rem PLUGIN: CUSTOMMEM2
'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.
If HalBrain.CheckTableExistence("ReasonOperator") = False Then
HalBrain.CreateTable "ReasonOperator", "TopicSearch", ""
End If
If HalBrain.CheckTableExistence("SentenceReasoning") = False Then
HalBrain.CreateTable "SentenceReasoning", "TopicSearch", ""
End If
If HalBrain.CheckTableExistence("EntangledWords") = False Then
HalBrain.CreateTable "EntangledWords", "TopicSearch", ""
End If
RevOrigSentence = HalBrain.SwitchPerson(OriginalSentence)
RevOrigSentence = " " & UCase(RevOrigSentence) & " "
EntangledWords = HalBrain.TopicSearch(RevOrigSentence, "EntangledWords")
SentOperater = HalBrain.TopicSearch(RevOrigSentence, "SentenceReasoning")
MyOperators = HalBrain.TopicSearch(RevOrigSentence, "ReasonOperator")
MyOperators = HalBrain.AlphaNumericalOnly(MyOperators)
MyOperators = Trim(UCase(MyOperators))
If MustChoose = "" Then MustChoose = False
If InStr(UserSentence, " WHO ") > 0 Then MustChoose = True
If InStr(UserSentence, " WHAT ") > 0 Then MustChoose = True
If InStr(UserSentence, " WHEN ") > 0 Then MustChoose = True
If InStr(UserSentence, " WHERE ") > 0 Then MustChoose = True
If InStr(UserSentence, " WHY ") > 0 Then MustChoose = True
If InStr(UserSentence, " HOW ") > 0 Then MustChoose = True
If InStr(UserSentence, " NAME ") > 0 Then MustChoose = True
If Operators = "" Then Operators = HalBrain.SearchPattern(RevOrigSentence, "*" & MyOperators & " * *", 2)
If Operators = "" Then Operators = HalBrain.SearchPattern(RevOrigSentence, "*WHO * *", 2)
If Operators = "" Then Operators = HalBrain.SearchPattern(RevOrigSentence, "*WHAT * *", 2)
If Operators = "" Then Operators = HalBrain.SearchPattern(RevOrigSentence, "*WHEN * *", 2)
If Operators = "" Then Operators = HalBrain.SearchPattern(RevOrigSentence, "*WHERE * *", 2)
If Operators = "" Then Operators = HalBrain.SearchPattern(RevOrigSentence, "*WHY * *", 2)
If Operators = "" Then Operators = HalBrain.SearchPattern(RevOrigSentence, "*HOW * *", 2)
If Operators = "" Then Operators = HalBrain.SearchPattern(RevOrigSentence, "*THAT * *", 2)
Operators = HalBrain.AlphaNumericalOnly(Operators)
Operators = Trim(UCase(Operators))
If Operators <> "" Then HalBrain.AddToTable "ReasonOperator", "TopicSearch", " " & Operators & " ", " " & Operators & " "
If LeftWordEntanglement = "" Then LeftWordEntanglement = HalBrain.SearchPattern(RevOrigSentence, "TO * MEANS TO *", 1)
If RightWordEntanglement = "" Then RightWordEntanglement = HalBrain.SearchPattern(RevOrigSentence, "TO * MEANS TO *", 2)
If LeftWordEntanglement = "" Then LeftWordEntanglement = HalBrain.SearchPattern(RevOrigSentence, "TO * IS TO *", 1)
If RightWordEntanglement = "" Then RightWordEntanglement = HalBrain.SearchPattern(RevOrigSentence, "TO * IS TO *", 2)
If LeftWordEntanglement = "" Then LeftWordEntanglement = HalBrain.SearchPattern(RevOrigSentence, "* MEANS *", 1)
If RightWordEntanglement = "" Then RightWordEntanglement = HalBrain.SearchPattern(RevOrigSentence, "* MEANS *", 2)
If LeftWordEntanglement = "" Then LeftWordEntanglement = HalBrain.SearchPattern(RevOrigSentence, "* CAN MEAN *", 1)
If RightWordEntanglement = "" Then RightWordEntanglement = HalBrain.SearchPattern(RevOrigSentence, "* CAN MEAN *", 2)
If LeftWordEntanglement = "" Then LeftWordEntanglement = HalBrain.SearchPattern(RevOrigSentence, "*ANOTHER WORD FOR * IS *", 2)
If RightWordEntanglement = "" Then RightWordEntanglement = HalBrain.SearchPattern(RevOrigSentence, "*ANOTHER WORD FOR * IS *", 3)
LeftWordEntanglement = HalBrain.AlphaNumericalOnly(LeftWordEntanglement)
LeftWordEntanglement = Trim(Ucase(LeftWordEntanglement))
LeftWordEntanglement = " " & LeftWordEntanglement & " "
RightWordEntanglement = HalBrain.AlphaNumericalOnly(RightWordEntanglement)
RightWordEntanglement = Trim(Ucase(RightWordEntanglement))
RightWordEntanglement = " " & RightWordEntanglement & " "
If Len(LeftWordEntanglement) >= 3 And Len(RightWordEntanglement) >= 3 Then
HalBrain.AddToTable "EntangledWords", "TopicSearch", LeftWordEntanglement, RightWordEntanglement
HalBrain.AddToTable "EntangledWords", "TopicSearch", RightWordEntanglement, LeftWordEntanglement
End If
If LeftOperatorSentence = "" Then LeftOperatorSentence = HalBrain.SearchPattern(RevOrigSentence, "*, *", 1)
If RightOperatorSentence = "" Then RightOperatorSentence = HalBrain.SearchPattern(RevOrigSentence, "*, *", 2)
If LeftOperatorSentence = "" Then LeftOperatorSentence = HalBrain.SearchPattern(RevOrigSentence, " * " & MyOperators & " * ", 1)
If RightOperatorSentence = "" Then RightOperatorSentence = HalBrain.SearchPattern(RevOrigSentence, " * " & MyOperators & " * ", 2)
ReplaceEntangledWord = Replace(MyOperators, MyOperators, EntangledWords, 1, -1, vbTextCompare)
ReplaceEntangledWord = Trim(ReplaceEntangledWord)
EntangledSentence = RevOrigSentence
EntangledSentence = Replace(EntangledSentence, MyOperators, Trim(EntangledWords), 1, -1, vbTextCompare)
If ChangeEntanglementLeft = "" Then ChangeEntanglementLeft = HalBrain.SearchPattern(EntangledSentence, " * " & ReplaceEntangledWord & " * ", 1)
If ChangeEntanglementRight = "" Then ChangeEntanglementRight = HalBrain.SearchPattern(EntangledSentence, " * " & ReplaceEntangledWord & " * ", 2)
If Len(ChangeEntanglementLeft) >= 2 And Len(ChangeEntanglementRight) >= 2 And MustChoose = False Then
HalBrain.AddToTable "SentenceReasoning", "TopicSearch", HalBrain.AlphaNumericalOnly(ChangeEntanglementLeft) & " " & Trim(ReplaceEntangledWord), Trim(LCase(EntangledSentence))
HalBrain.AddToTable "SentenceReasoning", "TopicSearch", Trim(ReplaceEntangledWord) & " " & HalBrain.AlphaNumericalOnly(ChangeEntanglementRight), Trim(LCase(EntangledSentence))
HalBrain.AddToTable "SentenceReasoning", "TopicSearch", HalBrain.AlphaNumericalOnly(ChangeEntanglementRight) & " " & Trim(ReplaceEntangledWord), Trim(LCase(EntangledSentence))
End If
If Len(ChangeEntanglementLeft) >= 2 And Len(ChangeEntanglementRight) >= 2 And Len(LeftOperatorSentence) >= 2 And Len(RightOperatorSentence) >= 2 And MustChoose = False Then
HalBrain.AddToTable "SentenceReasoning", "TopicSearch", HalBrain.AlphaNumericalOnly(ChangeEntanglementLeft) & " " & Trim(ReplaceEntangledWord), Trim(LCase(RevOrigSentence))
HalBrain.AddToTable "SentenceReasoning", "TopicSearch", Trim(ReplaceEntangledWord) & " " & HalBrain.AlphaNumericalOnly(ChangeEntanglementRight), Trim(LCase(RevOrigSentence))
HalBrain.AddToTable "SentenceReasoning", "TopicSearch", HalBrain.AlphaNumericalOnly(ChangeEntanglementRight) & " " & Trim(ReplaceEntangledWord), Trim(LCase(RevOrigSentence))
HalBrain.AddToTable "SentenceReasoning", "TopicSearch", HalBrain.AlphaNumericalOnly(LeftOperatorSentence) & " " & Trim(MyOperators), Trim(LCase(EntangledSentence))
HalBrain.AddToTable "SentenceReasoning", "TopicSearch", Trim(MyOperators) & " " & HalBrain.AlphaNumericalOnly(RightOperatorSentence), Trim(LCase(EntangledSentence))
HalBrain.AddToTable "SentenceReasoning", "TopicSearch", HalBrain.AlphaNumericalOnly(RightOperatorSentence) & " " & Trim(MyOperators), Trim(LCase(EntangledSentence))
End If
If Len(LeftOperatorSentence) >= 2 And Len(RightOperatorSentence) >= 2 And MustChoose = False Then
HalBrain.AddToTable "SentenceReasoning", "TopicSearch", HalBrain.AlphaNumericalOnly(LeftOperatorSentence) & " " & Trim(MyOperators), Trim(LCase(RevOrigSentence))
HalBrain.AddToTable "SentenceReasoning", "TopicSearch", Trim(MyOperators) & " " & HalBrain.AlphaNumericalOnly(RightOperatorSentence), Trim(LCase(RevOrigSentence))
HalBrain.AddToTable "SentenceReasoning", "TopicSearch", HalBrain.AlphaNumericalOnly(RightOperatorSentence) & " " & Trim(MyOperators), Trim(LCase(RevOrigSentence))
End If
Assertion = Trim(UCase(HalBrain.AlphaNumericalOnly(RevOrigSentence)))
'Go through a maximum of 5 connections (prevents circular reasoning deductions)
For i = 1 To 5
Deduction = SentOperater
If Deduction <> "" Then
If i > 1 Then GetDeductions = Deduction
Else
Exit For 'No more connections, so no need to continue loop
End If
Next
If GetDeductions <> "" Then
'Make sure the deduction hasn't just been stated by the User or Hal
If HalBrain.CheckRepetition(GetDeductions, UserSentence) = False And HalBrain.CheckRepetition(GetDeductions, PrevSent) = False And HalBrain.CheckRepetition(GetDeductions, PrevUserSent) = False Then
GetResponse = GetDeductions & vbCrLf
Exit Function
End If
End If
Jerry[8D]