I started writing this at 8:00 P.M.
I've never been a believer in limits. I have a little bit of Aspergers (autism). I may not have to be led around like an invalid, but when I look at other people I always feel like they are strangers (even my own parents, a trait of aspergers). I spent most of my life not being able to relate to people. But that doesn't stop me. Every day I look and listen, and always study people. I fight to grow, until the day comes when all learning becomes easy and no one is a stranger. Until that day, I will strengthen my weaknesses and never give in.
I already figured what some of your problems were, afterall, I've been studying people intensely for the last 34 years. :-) That's one reason why I'm trying to help you.
Secondly, adjectives and adverbs are a programmers best friend. You just need to think about them in the right way. English is just a type of database. You can pull information from it and send information around with it.
The Time is now 8:30 P.M.
Here is your code rewritten with that function I made. I formatted it a little different than yours. I use to this style more.
If vrChoice0 = "" Then
If vrChoice0 = "" Then
If SearchArray(vrd, Array("PET", "PET.", "PET,", "BOVIDAE", "DOMESTICATED", "RODENT", "MAMMAL", "KITTEN", "ANIMAL", "LIVESTOCK", "CREATURE", "BUG", "INSECT", "DOG", "CAT", "BIRD")) = True then
vrChoice0 = "ANIMAL"
End If
End If
If vrChoice0 = "ANIMAL" Then
If SearchArray(vrd, Array("HIM", "BEST FRIEND", "ACTRESS", "ACTOR", "ENTERTAINER", "FEMALE", "MALE", "HIS", "HER", "HE'S", "HE", "SHE", "PERSON", "HUMAN", "CHILD")) = True then
vrChoice0 = "PERSON"
End If
End If
If vrChoice0 = "" Then
If SearchArray(vrd, Array("BORN", "HIM", "BEST FRIEND", "ACTRESS", "ACTOR", "ENTERTAINER", "FEMALE", "MALE", "HIS", "HER", "HE'S", "HE", "SHE", "PERSON", "HUMAN", "CHILD")) = True Then
vrChoice0 = "PERSON"
End If
End If
If vrChoice0 = "PERSON" Then
If SearchArray(vrd, Array("ORGANIC", "COMPOUNDS")) = True Then
vrChoice0 = ""
End If
End If
If vrChoice0 = "PERSON" Then
If SearchArray(vrd, Array("A ROBIN", "A MARTIN")) = True Then
vrChoice0 = "ANIMAL"
End If
End If
If vrChoice0 = "PERSON" Then
Dim personSex2() 'We must declare an empty array to store query results in
newline = Replace(HalBrain.AlphaNumericalOnly(OriginalSentence), "'", "''")
If HalBrain.RunQuery("SELECT searchString, topic FROM names WHERE strstr(' " & newline & " ', searchString) > 0 LIMIT 1", personSex2) = True Then
vrpersonsSex = Trim(personSex2(1, 1)) 'Row 1, Column 1 contains "topic", which is the associated gender(s) of the name
End If
End If
If vrChoice0 = "" Then
If SearchArray(vrd, Array("BALLET", "OPERA", "THEATRE", "MOVIE", "PLAY", "PLAYING", "POETRY", "POEM", "GAME", "MUSIC", "FILM", "TELEVISION")) = True Then
vrChoice0 = "ENTERTAINMENT"
End If
End If
If vrChoice0 = "" Then
If SearchArray(vrd, Array("HOUSE", "PLACE", "LOCATED", "FARM", "LOCATION", "CITY", "COUNTRY", "CAPITAL", "STORE", "HOME", "HOUSE", "PARK", "MALL", "WORLD", "STATE", "JOB", "SCHOOL" )) = True Then
vrChoice0 = "PLACE"
End If
End If
If vrChoice0 = "PLACE" Then
If SearchArray(vrd, Array("ORGANIC", "COMPOUNDS")) = True Then
vrChoice0 = ""
End If
End If
If vrChoice0 = "" Then
If SearchArray(vrd, Array("COMPUTER", "TELEPHONE", "LAPTOP", "CENTRAL PROCESSING UNIT", "PROCESSOR" , "CPU")) = True Then
vrChoice0 = "COMPUTER"
End If
End If
If vrChoice0 = "" Then
If SearchArray(vrd, Array("FLOWER", "COLOR", "COLOUR", "PLANT", "FOOD" , "DIRT", "TREE", "TREES", "GRASS", "VEGETABLE", "MINERAL", "FRUIT", "LIQUID", "CULTIVATED", "SHRUB")) = True Then
vrChoice0 = "MINERAL"
End If
End If
If vrChoice0 <> "" Then
vrChoice4 = vrChoice0
HalBrain.AddToTable "vrsubject2sub", "TopicSearch", vrItem0, vrChoice0
End If
Else
vrChoice4 = vrChoice0
End If
Wscript.Echo vrChoice0
Function SearchArray(StringToSearch, WordsToLookUp)
StringToSearch = " " & LCase(StringToSearch) & " "
For Each word In WordsToLookUp
word = " " & LCase(word) & " "
If InStr(StringToSearch,word) > 0 Then
SearchArray = True
Exit Function
End If
Next
SearchArray = False
End Function
The Time is now: 9:50 PM
I tend to use nested If statements formatted like this:
If x = 1 then
If y = 1 then
If z = 1 then
End If
End If
End If
But its all up to the programmer preference. Its all good
.
…...
…...
The ( _ ) character is called an underscore. It is used in Vbscript to allow the programmer to extend a function to different lines. For instance you could write this:
input = "hello world"
Text1 = Replace(input, "world", "cload")
'Text1 will now equal "hello cload"
Or you could write this and it will also work just fine:
input = "hello world"
Text1 = Replace _
(input, _
"world", _
"wookie")
Notice that there is one space between the last character and the ( _ ) character. It is needed.
'These two examples mean the same thing
If name = "bill" Or name = "ted" Or name = "fred" Then
End If
If name = "bill" _
Or name = "ted" _
Or name = "fred" Then
End If
ByRef literally means that you are passing a variable to a function by its reference address. To understand what that means you will first need to lean how a computer stores information.
Let's first look at this statement:
myVar = "Hello Cload"
When you store a string in a variable your computer first looks for some empty space on your hard-drive. When it finds it, it remembers its location. Think of it as having a mailing address to send a letter. A mailing address will indicate where a person lives, the city, street, apartment, etc. Basically, Vbscript will find an address of an empty storage space on your hard-drive so that your variable (myVar) can store information there (“Hello Cload”).
In this Example we will pass a variable to a normal Function. Notice that the Function has a statement of ByVal preceding the input variable. ByVal means 'by value'. It is the Default way Functions and Subs take in variables.
The Time is now 10:30 PM
The Time is now 11:00 PM
out = Delete(myVar)
Function Delete(ByVal input)
input = ""
Delete = input
End Function
What happens here is that the content of your variable (myVar) is copied into the Function's variable (input). Remember what I said about Vbscript storing the data somewhere on your hard-drive, well, Vbscript goes to the address of the stored information in the myVar variable, takes that information, and copies it into the input variable contained in the Delete Function. It is the same as if I drove to a friend's house and copied their letter and then gave it to my brother.
Now look at this Sub (and Remember Subs can't return anything):
Delete myVar
Sub Delete(ByRef input)
input = ""
End Sub
What's happening in this Example is that the address of the myVar variable is shared with the input variable. It doesn't copy the content (“Hello Cload”) it only copies the Address. It is like, instead of me going to a friend's house and copying there letter, I simply gave my brother the address of my friends house. So now my brother can go to my friend's house and do whatever with the letter. The input variable in the Delete Sub gives the Delete Sub direct access to the myVar variable address. I can do whatever I want to the input variable and it will effect the myVar variable directly.
If I delete the content of the input variable in the Delete Function then the myVar variable content will be deleted. If I add content to the input variable then the myVar variable will be added to. So whatever I do to the one, it will do to the other.
Its actually a little tricky to understand this but its useful. If you use the ByRef statement in either the Function or the Sub then your myVar content will be effected. If you wanted to keep that information safe then you should use the ByVal statement so that it will just copy the content. That is how you determine when to use them.
The Time is now 12:11 AM
…...
condition 1: the user did not give an explanation to keep ultra Hal on topic. If the user did give a stronger rebuttal such as example above do not process the yes.
Condition 2: the answer yes or its variants counterpart will not interfere with the normal function of ultra Hals brain or with the free will plug-in.
…...
I reexamined UltraHal's Brain Script and Looked deeper into your plugin.
It seems we have this obvious problem of Hal not letting the User use the GetResponse Function if its a yes or no Input. There are a few work-a-rounds like some of the suggestions you've said already. I thought of similar alternatives but none really fix the problem better than your ideas (outside of modifying the brain itself). However, there is one crazy solution that you might not have thought of. One could call the GetResponse() Function from the Pre-Process area when the input (IS) yes or no. Yeah, I know, think'n crazy thoughts.
Rem PLUGIN: PRE-PROCESS
InputString = PreProcess(InputString)
InputString2 = Replace(InputString, ".", " ")
InputString2 = Replace(InputString2, "?", " ")
InputString2 = Replace(InputString2, "!", " ")
InputString2 = " " & Replace(InputString2, ",", " ") & " "
YesNoDetect = HalBrain.TopicSearch(InputString2, "yesNoDetect")
If YesNoDetect = "Yes" Or YesResponse = "No" Then
UltraHal = GetResponse(InputString, UserName, ComputerName, LearningLevel, HalCommands, Hate, Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent, CustomMem, GainControl, LastTopicList)
End If
Rem PLUGIN: FUNCTIONS
Function PreProcess(InputString)
InputString = Replace(InputString, "MR.", "Mr<PERIOD>", 1, -1, vbTextCompare)
InputString = Replace(InputString, "MRS.", "Mrs<PERIOD>", 1, -1, vbTextCompare)
InputString = Replace(InputString, "MS.", "Ms<PERIOD>", 1, -1, vbTextCompare)
InputString = Replace(InputString, "DR.", "Dr<PERIOD>", 1, -1, vbTextCompare)
InputString = Replace(InputString, "MS.", "Ms<PERIOD>", 1, -1, vbTextCompare)
InputString = Replace(InputString, "ST.", "St<PERIOD>", 1, -1, vbTextCompare)
InputString = Replace(InputString, "PROF.", "Prof<PERIOD>", 1, -1, vbTextCompare)
InputString = Replace(InputString, "GEN.", "Gen<PERIOD>", 1, -1, vbTextCompare)
InputString = Replace(InputString, "REP.", "Rep<PERIOD>", 1, -1, vbTextCompare)
InputString = Replace(InputString, "SEN.", "Sen<PERIOD>", 1, -1, vbTextCompare)
'Remove unnecessary punctuation
Do
RepeatLoop = False
If InStr(InputString, "..") Then InputString = Replace(InputString, "..", "."): RepeatLoop = True
If InStr(InputString, "??") Then InputString = Replace(InputString, "??", "?"): RepeatLoop = True
If InStr(InputString, "!!") Then InputString = Replace(InputString, "!!", "!"): RepeatLoop = True
If InStr(InputString, "!?") Then InputString = Replace(InputString, "!?", "?"): RepeatLoop = True
If InStr(InputString, "?!") Then InputString = Replace(InputString, "?!", "?"): RepeatLoop = True
If InStr(InputString, ",,") Then InputString = Replace(InputString, ",,", ","): RepeatLoop = True
Loop While RepeatLoop = True
'Detect and encode acronyms such as U.S.A.
InputString = Trim(InputString)
WordList = Split(InputString, " ")
For i = 0 To UBound(WordList)
If Len(WordList(i)) > 3 Then
If Right(WordList(i), 1) = "." And Mid(WordList(i), Len(WordList(i)) - 2, 1) = "." Then
InputString = Replace(InputString, WordList(i), Left(WordList(i), Len(WordList(i)) - 1) & "<PERIOD>")
End If
End If
Next
End Function
The Time is now 3:28 AM
…...
…...
By the way, this next Example will search a string for the existance of any set of words. Basically, if the word “correct” or “affirmative” or any of the other words is in the OriginalSentence then it will return True. It is not using any tables. It doesn't need the “yesnodetect” array table.
If SearchArray(OriginalSentence, Array("yes","indeed","correct","affirmative", "positive", "yep")) = true Then
End If
Function SearchArray(compare, arrayToSearch)
compare = LCase(compare)
For Each word In arrayToSearch
word = LCase(word)
If InStr(compare, word) > 0 Then
SearchArray = True
Exit Function
End If
Next
SearchArray = False
End Function
I would answer some more questions but I need to sleep now... It's 3:45 AM.