· 9 years ago · Nov 13, 2016, 10:24 PM
1Rem Type=Brain
2Rem Name=Super Plugger Brain
3Rem Author=cyberjedi
4Rem Language=VBScript
5Rem DB=HalBrain.db
6
7'Please read about changes in this default brain below.
8
9'This Alice Super Plugger Brain enhancement was modified by cyberjedi.
10'and was designed to be a point handler default brain for better point to point plug-in
11'control and abilities.
12
13'Modifications were: this brain was given PLUGIN commands between each GetResponse
14'throughout the entire brain and was design to meet the requirements of the new
15'D.A.V.I.D plug-ins written by Gerald L. Blakley
16
17'The UltraHal function is called by Ultra Hal Assistant 6.0 or a compatible host application
18'It passes an unformated string of the user's input as well as all remembered variables.
19'The UltraHal function splits the user's input into seperate sentences and than calls
20'GetResponse to get a response for each user sentence. The UltraHal function performs all
21'the initialization functions required for GetResponse so that GetResponse doesn't have to
22'initialize several times if a user inputs more than 1 sentence.
23Function UltraHal(ByVal InputString, ByVal UserName, ByVal ComputerName, ByVal LearningLevel, ByVal DatabaseFile, ByRef Hate, ByRef Swear, ByRef Insults, ByRef Compliment, ByRef PrevSent, ByRef LastResponseTime, ByRef PrevUserSent, ByRef CustomMem, ByRef GainControl, ByRef LastTopicList)
24
25 'RESPOND: User pressed enter, but didn't say anything
26 InputString = Trim(InputString)
27 If Len(InputString) < 2 Then
28 UltraHal = "Please say something."
29 Exit Function
30 End If
31
32 'PROCESS: AUTO-IDLE
33 'If AUTO-IDLE is enabled, it is called by the Ultra Hal Assistant host
34 'application at a set interval. This allows for the possibility of Hal
35 'being the first to say something if the user is idle.
36 If InputString = "AUTO-IDLE" Then
37 Rem PLUGIN: AUTO-IDLE
38 'The preceding comment is actually a plug-in directive for
39 'the Ultra Hal host application. It allows for code snippets
40 'to be inserted here on-the-fly based on user configuration.
41
42 UltraHal = UltraHal & HalBrain.StoreVars(HalCommands, Hate, Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent, CustomMem, GainControl, LastTopicList)
43 Exit Function
44 End If
45
46 'PROCESS: INITIALIZE VARIABLES
47 'VBScript doesn't allow you to declare variables in advance as a
48 'particular data type; everything is a Variant. We must assign
49 'integers to the following variants so that data type errors don't
50 'occur
51 If LearningLevel = "" Then LearningLevel = 0
52 If Hate = "" Then Hate = 0
53 If Swear = "" Then Swear = 0
54 If Insults = "" Then Insults = 0
55 If Compliment = "" Then Compliment = 0
56 If GainControl = "" Then GainControl = 25
57
58 'PROCESS: IF NO LEARNING IS REQUESTED, PUT DATABASE IN READ-ONLY MODE
59 'If read only mode is on, any requests to create a new table, add to
60 'a table, or delete records from a table will be ignored.
61 If LearningLevel = 0 Then HalBrain.ReadOnlyMode = True Else HalBrain.ReadOnlyMode = False
62
63 'PROCESS: EMOTIONAL FACTOR CENTERING
64 'We help Hal regain his emotional "center" gradually, even if the
65 'user doesn't catch on to dealing With Hal's feelings. The following
66 'code brings Hal's memory of hate, swearing, and insults gradually
67 'and randomly back to zero.
68 SpinWheel = Int(Rnd * 100)
69 If Hate > 0 And SpinWheel < 10 Then Hate = Hate - 1
70 If Swear > 0 And SpinWheel < 10 Then Swear = Swear - 1
71 If Insults > 0 And SpinWheel < 10 Then Insults = Insults - 1
72
73 'PROCESS: EMOTIONAL VARIETY
74 'The following code allows Hal some random emotional excursions:
75 SpinWheel = Int(Rnd * 100)
76 If Compliment = 4 And SpinWheel < 30 Then Compliment = 2
77 If Compliment > 0 And Compliment < 4 And SpinWheel < 5 Then Compliment = 0
78 If Compliment > 4 And SpinWheel < 5 Then Compliment = 0
79 If Compliment < 0 And SpinWheel < 30 Then Compliment = 0
80 If SpinWheel > 80 And SpinWheel < 90 Then Compliment = 2
81 If SpinWheel > 90 And SpinWheel < 95 Then Compliment = 4
82
83 Rem PLUGIN: PRE-PROCESS
84 'The preceding comment is actually a plug-in directive for
85 'the Ultra Hal host application. It allows for code snippets
86 'to be inserted here on-the-fly based on user configuration.
87
88 'PROCESS: SPLIT USER'S INPUT STRING INTO SEPERATE SENTENCES
89 'Encode abbreviations such as Mr. Mrs. and Ms.
90 InputString = Replace(InputString, "MR.", "Mr<PERIOD>", 1, -1, vbTextCompare)
91 InputString = Replace(InputString, "MRS.", "Mrs<PERIOD>", 1, -1, vbTextCompare)
92 InputString = Replace(InputString, "MS.", "Ms<PERIOD>", 1, -1, vbTextCompare)
93 InputString = Replace(InputString, "DR.", "Dr<PERIOD>", 1, -1, vbTextCompare)
94 InputString = Replace(InputString, "MS.", "Ms<PERIOD>", 1, -1, vbTextCompare)
95 InputString = Replace(InputString, "ST.", "St<PERIOD>", 1, -1, vbTextCompare)
96 InputString = Replace(InputString, "PROF.", "Prof<PERIOD>", 1, -1, vbTextCompare)
97 InputString = Replace(InputString, "GEN.", "Gen<PERIOD>", 1, -1, vbTextCompare)
98 InputString = Replace(InputString, "REP.", "Rep<PERIOD>", 1, -1, vbTextCompare)
99 InputString = Replace(InputString, "SEN.", "Sen<PERIOD>", 1, -1, vbTextCompare)
100 'Remove unnecessary punctuation
101 Do
102 RepeatLoop = False
103 If InStr(InputString, "..") Then InputString = Replace(InputString, "..", "."): RepeatLoop = True
104 If InStr(InputString, "??") Then InputString = Replace(InputString, "??", "?"): RepeatLoop = True
105 If InStr(InputString, "!!") Then InputString = Replace(InputString, "!!", "!"): RepeatLoop = True
106 If InStr(InputString, "!?") Then InputString = Replace(InputString, "!?", "?"): RepeatLoop = True
107 If InStr(InputString, "?!") Then InputString = Replace(InputString, "?!", "?"): RepeatLoop = True
108 If InStr(InputString, ",,") Then InputString = Replace(InputString, ",,", ","): RepeatLoop = True
109 Loop While RepeatLoop = True
110 'Detect and encode acronyms such as U.S.A.
111 InputString = Trim(InputString)
112 WordList = Split(InputString, " ")
113 For i = 0 To UBound(WordList)
114 If Len(WordList(i)) > 3 Then
115 If Right(WordList(i), 1) = "." And Mid(WordList(i), Len(WordList(i)) - 2, 1) = "." Then
116 InputString = Replace(InputString, WordList(i), Left(WordList(i), Len(WordList(i)) - 1) & "<PERIOD>")
117 End If
118 End If
119 Next
120 'Place split markers in string
121 InputString = Replace(InputString, ". ", ". <NEWSENT>")
122 InputString = Replace(InputString, "? ", "? <NEWSENT>")
123 InputString = Replace(InputString, "! ", "! <NEWSENT>")
124 'Decode acronyms and abbreviations
125 InputString = Replace(InputString, "<PERIOD>", ".", 1, -1, vbTextCompare)
126 'Split string into sentences
127 Sentences = Split(InputString, "<NEWSENT>")
128
129 'PROCESS: RECORD DEBUG INFO
130 HalBrain.AddDebug "Debug", "Ultra Hal Start"
131
132 'RESPOND: PREDEFINED RESPONSES
133 'If the previous exchange had tags to set the response of this exchange
134 'then follow the command.
135 NextResponse = HalBrain.ExtractVar(CustomMem, "NextResponse")
136 If NextResponse <> "" Then
137 CustomMem = Replace(CustomMem, "NextResponse-eq-", "LastResponse-eq-")
138 UltraHal = NextResponse
139 GoodSentence = True
140 NextResponse = ""
141 End If
142 YesResponse = HalBrain.ExtractVar(CustomMem, "YesRes")
143 NoResponse = HalBrain.ExtractVar(CustomMem, "NoRes")
144 If YesResponse <> "" Or NoResponse <> "" Then
145 CustomMem = Replace(CustomMem, "YesRes-eq-", "LastYesRes-eq-")
146 CustomMem = Replace(CustomMem, "NoRes-eq-", "LastNoRes-eq-")
147 InputString2 = Replace(InputString, ".", " ")
148 InputString2 = Replace(InputString, "?", " ")
149 InputString2 = Replace(InputString, "!", " ")
150 InputString2 = " " & Replace(InputString, ",", " ") & " "
151 YesNoDetect = HalBrain.TopicSearch(InputString2, "yesNoDetect")
152 If YesNoDetect = "Yes" And YesResponse <> "" Then
153 UltraHal = YesResponse
154 GoodSentence = True
155 ElseIf YesNoDetect = "No" And NoResponse <> "" Then
156 UltraHal = NoResponse
157 GoodSentence = True
158 End If
159 End If
160
161 'RESPOND: GETRESPONSE
162 'Get a response from Hal's brain for each sentence individually.
163 'If a response from a sentence indicates a special flag, then Hal
164 'will give only the response to that sentence, and not process
165 'any other sentences. Otherwise Hal will respond to each sentence.
166 'Hal will respond to a max of 3 sentences at once.
167 SentenceCount = UBound(Sentences)
168 If SentenceCount > 2 Then SentenceCount = 2
169 LowQualityResponse = ""
170 If GoodSentence = True Then SentenceCount = -1
171 For i = 0 To SentenceCount
172 TempParent = HalBrain.AddDebug("Debug", "Begin Processing Sentence " & CStr(i + 1), vbCyan)
173 HalBrain.AddDebug TempParent, "Sentence: " & Sentences(i)
174 HalBrain.DebugWatch "", "NewSent"
175 Sentences(i) = Trim(Sentences(i))
176 If Len(Sentences(i)) > 1 Then
177 GoodSentence = True
178 CurResponse = GetResponse(Sentences(i), UserName, ComputerName, LearningLevel, HalCommands, Hate, Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent, CustomMem, GainControl, LastTopicList) & vbCrLf
179 If InStr(1, CurResponse, "<LOWQUALITY>", vbTextCompare) Then
180 'If Hal's response to the current sentence is of a low-quality nature, then we hold out
181 'for a better response with a different sentence, but if there is no better response
182 'then we will use only the first low-quality response we came across.
183 If LowQualityResponse = "" Then LowQualityResponse = CurResponse
184 ElseIf InStr(1, CurResponse, "<TOPIC>", vbTextCompare) Or InStr(1, CurResponse, "<YESRES>", vbTextCompare) Or InStr(1, CurResponse, "<EXCLUSIVE>", vbTextCompare) Then
185 'If Hal's response indicates an exclusivity tag, then we erase any response Hal may have
186 'already had, respond with the exclusive response, and cease processing more sentences
187 UltraHal = CurResponse & vbCrLf
188 Exit For
189 Else
190 'Since there are no special tags, we just append the new response to the previous one
191 'if the response was not already given
192 If InStr(1, UltraHal, CurResponse, vbTextCompare) = 0 Then UltraHal = UltraHal & " . " & CurResponse & vbCrLf
193 End If
194 'If we received a tag to stop processing more sentences, we leave the loop
195 If InStr(1, CurResponse, "<NOMORE>", vbTextCompare) Then Exit For
196 End If
197 Next
198 'If we have no normal quality responses, we will use out low quality response
199 UltraHal = Trim(UltraHal)
200 If UltraHal = "" Then UltraHal = Trim(LowQualityResponse)
201
202 'RESPOND: USER DIDN'T SAY ANYTHING
203 'If GoodSentence has not been set to true, then that means the user didn't
204 'type anything of use, so we ask the user to say something.
205 If GoodSentence = False Then
206 UltraHal = "Please say something."
207 End If
208
209 'PROCESS: PROCESS IN-SENTENCE TAGS
210 'the <TOPIC>*</TOPIC> tag sets what Hal's next response will be, no matter what the user says
211 NextResponse = HalBrain.SearchPattern(UltraHal, "*<TOPIC>*</TOPIC>*", 2)
212 If NextResponse <> "" Then
213 UltraHal = Replace(UltraHal, NextResponse, "", 1, -1, vbTextCompare)
214 UltraHal = Replace(UltraHal, "<TOPIC>", "", 1, -1, vbTextCompare)
215 UltraHal = Replace(UltraHal, "</TOPIC>", "", 1, -1, vbTextCompare)
216 NextResponse = Trim(Replace(NextResponse, "<TOPIC>", "", 1, -1, vbTextCompare))
217 CustomMem = CustomMem & HalBrain.EncodeVar(NextResponse, "NextResponse")
218 End If
219 'The <YES>*</YES> and <NO>*</NO> tag sets what Hal's response will be if the user says yes or no
220 UltraHal = Replace(UltraHal, "<YESRE>", "<YESRES>", 1, -1, vbTextCompare)
221 UltraHal = Replace(UltraHal, "</YESRE>", "</YESRES>", 1, -1, vbTextCompare)
222 UltraHal = Replace(UltraHal, "<YES>", "<YESRES>", 1, -1, vbTextCompare)
223 UltraHal = Replace(UltraHal, "</YES>", "</YESRES>", 1, -1, vbTextCompare)
224 UltraHal = Replace(UltraHal, "<NO>", "<NORES>", 1, -1, vbTextCompare)
225 UltraHal = Replace(UltraHal, "</NO>", "</NORES>", 1, -1, vbTextCompare)
226 YesRes = HalBrain.SearchPattern(UltraHal, "*<YESRES>*</YESRES>*", 2)
227 If YesRes <> "" Then
228 UltraHal = Replace(UltraHal, YesRes, "", 1, -1, vbTextCompare)
229 UltraHal = Replace(UltraHal, "<YESRES>", "", 1, -1, vbTextCompare)
230 UltraHal = Replace(UltraHal, "</YESRES>", "", 1, -1, vbTextCompare)
231 YesRes = Trim(Replace(YesRes, "<YESRES>", "", 1, -1, vbTextCompare))
232 CustomMem = CustomMem & HalBrain.EncodeVar(YesRes, "YesRes")
233 End If
234 NoRes = HalBrain.SearchPattern(UltraHal, "*<NORES>*</NORES>*", 2)
235 If NoRes <> "" Then
236 UltraHal = Replace(UltraHal, NoRes, "", 1, -1, vbTextCompare)
237 UltraHal = Replace(UltraHal, "<NORES>", "", 1, -1, vbTextCompare)
238 UltraHal = Replace(UltraHal, "</NORES>", "", 1, -1, vbTextCompare)
239 NoRes = Trim(Replace(YesRes, "<NORES>", "", 1, -1, vbTextCompare))
240 CustomMem = CustomMem & HalBrain.EncodeVar(NoRes, "NoRes")
241 End If
242 'The <RUN>*</RUN> tags are converted into a HalCommand to run a program
243 UltraHal = Replace(UltraHal, "<RUNIT>", "<RUN>", 1, -1, vbTextCompare)
244 UltraHal = Replace(UltraHal, "</RUNIT>", "</RUN>", 1, -1, vbTextCompare)
245 RunProgram = HalBrain.SearchPattern(UltraHal, "*<RUN>*</RUN>*", 2)
246 If RunProgram <> "" Then
247 UltraHal = Replace(UltraHal, RunProgram, "", 1, -1, vbTextCompare)
248 UltraHal = Replace(UltraHal, "<RUN>", "", 1, -1, vbTextCompare)
249 UltraHal = Replace(UltraHal, "</RUN>", "", 1, -1, vbTextCompare)
250 RunProgram = Trim(Replace(YesRes, "<RUN>", "", 1, -1, vbTextCompare))
251 HalCommands = HalCommands & "<RUNPROG>" & RunProgram & "</RUNPROG>"
252 End If
253 UltraHal = Replace(UltraHal, "<WEBADDRESS>", "www.ultrahal.com", 1, -1, vbTextCompare)
254 UltraHal = Replace(UltraHal, "<HALNAME>", ComputerName, 1, -1, vbTextCompare)
255 UltraHal = Replace(UltraHal, "<HALSNAME>", ComputerName, 1, -1, vbTextCompare)
256 UltraHal = Replace(UltraHal, "<COMPUTERNAME>", ComputerName, 1, -1, vbTextCompare)
257 UltraHal = Replace(UltraHal, " " & ComputerName & " ", " " & ComputerName & " ", 1, -1, vbTextCompare)
258 UltraHal = Replace(UltraHal, "<TIME>", Time(), 1, -1, vbTextCompare)
259 UltraHal = Replace(UltraHal, "<DATE>", Date(), 1, -1, vbTextCompare)
260 UltraHal = Replace(UltraHal, "<QUOTE>", """", 1, -1, vbTextCompare)
261 UltraHal = Replace(UltraHal, """, """", 1, -1, vbTextCompare)
262 UltraHal = Replace(UltraHal, """, """", 1, -1, vbTextCompare)
263 UltraHal = Replace(UltraHal, "<AT>", "@", 1, -1, vbTextCompare)
264 UltraHal = Replace(UltraHal, "<NOMORE>", "", 1, -1, vbTextCompare)
265 UltraHal = Replace(UltraHal, "<LOWQUALITY>", "", 1, -1, vbTextCompare)
266 UltraHal = Replace(UltraHal, "<EXCLUSIVE>", "", 1, -1, vbTextCompare)
267
268 'PROCESS: INTELLIGENT CAPITILIZATION FIX
269 UltraHal = HalBrain.FixCaps(HalBrain.HalFormat(UltraHal))
270
271 Rem PLUGIN: POST-PROCESS
272 'The preceding comment is actually a plug-in directive for
273 'the Ultra Hal host application. It allows for code snippets
274 'to be inserted here on-the-fly based on user configuration.
275
276 'POST PROCESS: PRESERVE ALL VARIABLES, CLOSE DATABASE, EXIT
277 'Remember all the variables through encoding them into one function string using
278 'the DLL, since for some reason ByRef assignments don't work when a Visual Basic
279 'executable is calling a function in a VBScript program. The HalCommands variable
280 'that is returned is not used by this script, but can be used by script programmers
281 'to send certain commands back to the host Hal program. See documentation of the
282 'host Hal program to see what this can be used for.
283 'Close database and exit function
284 PrevSent = UltraHal
285 UltraHal = UltraHal & HalBrain.StoreVars(HalCommands, Hate, Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent, CustomMem, GainControl, LastTopicList)
286
287End Function
288
289
290Function GetResponse(ByVal UserSentence, ByVal UserName, ByVal ComputerName, ByVal LearningLevel, ByRef HalCommands, ByRef Hate, ByRef Swear, ByRef Insults, ByRef Compliment, ByVal PrevSent, ByRef LastResponseTime, ByRef PrevUserSent, ByRef CustomMem, ByRef GainControl, ByRef LastTopicList)
291
292 'PROCESS: DECODE CUSTOM VARIABLES FROM CUSTOMMEM VARIABLE
293 NewName = HalBrain.ExtractVar(CustomMem, "NewName")
294 UserSex = HalBrain.ExtractVar(CustomMem, "UserSex")
295 SentCount = HalBrain.ExtractVar(CustomMem, "SentCount")
296 If SentCount = "" Then SentCount = 0
297 SentCount = SentCount + 1
298 AvoidBeingFlag = False
299 Randomize
300
301 Rem PLUGIN: CUSTOMMEM
302 'The preceding comment is actually a plug-in directive for
303 'the Ultra Hal host application. It allows for code snippets
304 'to be inserted here on-the-fly based on user configuration.
305
306 'PROCESS: PRESERVE ORIGINAL SENTENCE
307 'Preserve the original user's sentence verbatim
308 '(no pronoun reversals or other processing).
309 OriginalSentence = UserSentence
310
311 'PROCESS: PREPARE FOR HALFORMAT AND REVERSE PERSON
312 'We try some pre-processing to try to prevent problems with the
313 'upcoming routines.
314 UserSentence = Replace("" & UserSentence & "", " I MYSELF ", " I, MYSELF, ", 1, -1, vbTextCompare)
315 UserSentence = Replace("" & UserSentence & "", " I'M ", " I AM ", 1, -1, vbTextCompare)
316 UserSentence = Replace("" & UserSentence & "", " YOU'RE ", " YOU ARE ", 1, -1, vbTextCompare)
317 UserSentence = Replace("" & UserSentence & "", " YOU YOURSELF ", " YOU, YOURSELF, ", 1, -1, vbTextCompare)
318 UserSentence = Replace("" & UserSentence & "", " I'M NOT ", " I AM NOT ", 1, -1, vbTextCompare)
319 UserSentence = Replace("" & UserSentence & "", " I'VE ", " I HAVE ", 1, -1, vbTextCompare)
320 UserSentence = Replace("" & UserSentence & "", "YOU'RE NOT ", "YOU ARE NOT ", 1, -1, vbTextCompare)
321 UserSentence = Replace("" & UserSentence & "", "YOU AREN'T ", "YOU ARE NOT ", 1, -1, vbTextCompare)
322 UserSentence = Replace("" & UserSentence & "", " YOU'VE ", " YOU HAVE ", 1, -1, vbTextCompare)
323 UserSentence = Replace("" & UserSentence & "", " I AM YOUR ", " VIMRQ ", 1, -1, vbTextCompare)
324 UserSentence = Replace("" & UserSentence & "", " YOU ARE MY ", " VURMQ ", 1, -1, vbTextCompare)
325
326 'PROCESS: SUBSTITUTE FOR PUNCTUATION
327 'The next routine removes hyphens etc., so we substitute for
328 'better word appearance later on.
329 UserSentence = Replace("" & UserSentence & "", "-", " VHZ ", 1, -1, vbTextCompare)
330 UserSentence = Replace("" & UserSentence & "", ";", " VSZ ", 1, -1, vbTextCompare)
331 UserSentence = Replace("" & UserSentence & "", ":", " VMZ ", 1, -1, vbTextCompare)
332 UserSentence = Replace("" & UserSentence & "", ", ", " VCZ ", 1, -1, vbTextCompare)
333
334 'PROCESS: REMOVE PUNCTUATION
335 'This function removes all punctuation and symbols from the User's
336 'sentence so they won't confuse Hal during processing.
337 UserSentence = HalBrain.AlphaNumericalOnly(UserSentence)
338
339 'PROCESS: MODIFY SENTENCE
340 'The function, HalFormat, from the ActiveX DLL corrects many common
341 'typos and chat shortcuts. Example: "U R Cool" becomes "You are
342 'cool." It also fixes a few grammatical errors.
343 UserSentence = HalBrain.HalFormat(UserSentence)
344
345 'PROCESS: REVERSE PERSON
346 'This function reverses first and second person pronouns. Example:
347 'The user's statement "You are cool" becomes Hal's statement "I am
348 'cool." Keep this is mind and don't get confused. When we are in
349 'Hal's brain; In the databases, "I" refers to Hal and in the
350 'databases, "you" refers to the user. This is true whenever we are
351 'dealing with a user response "processed" by Hal's brain.
352 UserSentence = HalBrain.SwitchPerson(UserSentence)
353
354 'PROCESS: MODIFY SENTENCE
355 'We now must run HalFormat again, to fix some grammatical errors
356 'the switch person above might have caused. Example: If the
357 'original sentence was "How are you"; after the function above it
358 'became "How are me" which is grammatically wrong. This will fix
359 'it to "How am I"
360 'NOTE TO DEVELOPERS: An especially important function performed by
361 'HalFormat is the removal of extra empty spaces in a sentence
362 'which may have been caused by other processing. For this reason,
363 'use Halformat closely before any "Len" comparison in which the
364 'counting of characters must be accurate.
365 UserSentence = HalBrain.HalFormat(UserSentence)
366
367 'PROCESS: CHANGE TO ALL CAPS
368 'Next, we captitalize the entire sentence for easy comparison.
369 'Almost all of Hal's thinking is done in caps.
370 UserSentence = UCase(UserSentence)
371
372 'PROCESS: WORD AND PHRASE SUBSTITUTIONS
373 'This will fix common errors in the user's sentence that the
374 'HalFormat function didn't take care of. These subsitutions are
375 'placed only the users sentence, not on Hal's responses. The
376 'HalFormat function is used on both Hal's and the user's sentences
377 'throughout the script.
378 UserSentence = HalBrain.ProcessSubstitutions(UserSentence, "substitutions")
379 TempParent = HalBrain.AddDebug("Debug", "Modified User Sentence")
380 HalBrain.AddDebug TempParent, "Sentence: " & UserSentence
381
382 'PROCESS: EMOTIONAL REACTIONS
383 'We enable Hal's expressions to respond to common verbal cues.
384 'The verbal cues are identified in the editable table "emotion"
385 EmotionalReaction = UCase(HalBrain.TopicSearch(UserSentence, "emotion"))
386 Select Case EmotionalReaction
387 Case "SURPRISED"
388 If Compliment > 0 Then Compliment = 4
389 If Compliment = 0 Then Compliment = 2
390 If Compliment < 0 Then Compliment = 0
391 Case "HAPPY"
392 If Compliment = 0 Then Compliment = 2
393 If Compliment < 0 Then Compliment = 0
394 Case "SOBER"
395 If Compliment < 4 Then Compliment = 0
396 If Compliment = 4 Then Compliment = 2
397 Case "ANGRY"
398 If Compliment = 0 Then Compliment = -1
399 If Compliment > 0 Then Compliment = 0
400 Case "SAD"
401 If Compliment = 0 Then Compliment = -2
402 If Compliment > 0 Then Compliment = 0
403 End Select
404
405 'PROCESS: ADD SPACES
406 'This will add spaces to the beggining and end of the user sentence to make
407 'sure that whole words can be found at the beginning and end of any sentence
408 UserSentence = " " & UserSentence & " "
409
410 'PROCESS: FIGURE OUT THE CURRENT SUBJECT
411 'Here we attempt to figure out the subject of the user's sentence. We call
412 'the WordNet class to find the first occurence of a noun in the User's
413 'sentence. Very often this is the subject of the sentence, but if not it
414 'will still most likely be relevant to the conversation.
415 CurrentSubject = WN.FindFirstNoun(UserSentence, True)
416 HalBrain.AddDebug "Debug", "Current Subject: " & CurrentSubject
417
418 'PROCESS: BLOCK LEARNING IF HAL'S NAME IS DETECTED
419 'Here we check to see if the user is calling Hal by name; if the user is doing so,
420 'it's better not to save the sentence for re-use, since it usually makes the
421 'pronoun-reversed sentence sound clumsy or incorrect:
422 If InStr(1, OriginalSentence, ComputerName, vbTextCompare) > 0 Then HalBrain.ReadOnlyMode = True
423
424 Rem PLUGIN: PLUGINAREA1
425'The comment above tells Ultra Hal Assistant to insert the following code
426'on-the-fly into the main brain code in the section referenced.
427
428Dim vrTopic, vrRssAddress, vrNews, vrTemp
429vrUserSentence = UserSentence
430
431'------------------
432'Check if the user is asking for latest news
433'------------------
434vrNews = ""
435vrWord = ""
436vrCategory = ""
437vrSearch = ""
438vrNews = InStr(vrUserSentence, "Latest Terrorist News")
439If vrNews > 0 Then
440 If vrWord = "" Then vrWord = HalBrain.SearchPattern(vrUserSentence, "* ABOUT *", 2)
441 HalBrain.ReadOnlyMode = True
442'------------------
443'Check if the user is asking for a specific text string
444'------------------
445 If vrWord <> "" Then
446 vrRssAddress = "http://www.homelandsecuritynewswire.com/rss"
447 vrSearch = "?search=" & vrWord
448 vrAnswerWord = " about " & UCase(vrWord)
449 Else
450 vrRssAddress = "http://www.homelandsecuritynewswire.com/rss"
451 vrSearch = ""
452 vrAnswerWord = ""
453 End If
454
455 HalCommands = HalCommands & "<RUNPROG>" & vrRssAddress & vrSearch & "</RUNPROG>"
456 Select Case (Int(Rnd * 4) + 1)
457 Case 1
458 GetResponse = "These are the latest news by Terrorist! News " & vrAnswerWord & " ." & vbCrLf
459 Case 2
460 GetResponse = "Now you can see the latest news " & vrAnswerWord & " ." & vbCrLf
461 Case 3
462 GetResponse = "I will open the browser on the latest news " & vrAnswerWord & " ." & vbCrLf
463 Case 4
464 GetResponse = "OK. Here you find the news " & vrAnswerWord & " ." & vbCrLf
465 Case 5
466 GetResponse = "I have found these news " & vrAnswerWord & " ." & vbCrLf
467 End Select
468End If
469
470
471
472
473
474If InStr(1, UserSentence, " INDEX BRAIN ", 1) > 0 Then
475 RsBrnDir = DudResearchDir3()
476 Set objFSO = CreateObject("Scripting.FileSystemObject")
477 RsBrnTableName = "RsBrn"
478 If HalBrain.CheckTableExistence(RsBrnTableName) = True Then
479 HalBrain.RunQuery "DELETE FROM " & RsBrnTableName, RsBrnTempQuery
480 Else
481 HalBrain.CreateTable RsBrnTableName, "Brain", ""
482 End If
483 objStartFolder = RsBrnDir
484 Set objFolder = objFSO.GetFolder(objStartFolder)
485 Set colFiles = objFolder.Files
486 For Each objFile in colFiles
487 RsBrnTfile = HalBrain.SearchPattern(UCase(objFile.Name), "*.TXT", 1)
488 If LenB(RsBrnTfile) <> 0 Then
489 set objTS = objFile.OpenAsTextStream(1, 0)
490 RsBrnText = RsBrnText & vbCrLf & objTS.Read(objFile.Size)
491 objTS.Close
492 End If
493 Next
494 RsBrnLineList = Split(RsBrnText, vbCrLf)
495 For Each RsBrnLine in RsBrnLineList
496 If Len(RsBrnLine) > 3 Then
497 RsBrnLearn = ""
498 If HalBrain.ReadOnlyMode = True Then
499 HalBrain.ReadOnlyMode = False
500 RsBrnLearn = True
501 Else
502 RsBrnLearn = False
503 End If
504 HalBrain.AddToTable RsBrnTableName, "Brain", UCase(Trim(HalBrain.AlphaNumericalOnly(RsBrnLine))), RsBrnLine
505 If RsBrnLearn = True Then HalBrain.ReadOnlyMode = True
506 End If
507 Next
508 GetResponse = "Re-index of external database complete." & vbCrLf & "<EXCLUSIVE>"
509 HalBrain.ReadOnlyMode = True
510End If
511
512ResearchSentence = OriginalSentence
513
514If ResearchSentence <> "" Then
515 MyResearchDir2 = DudResearchDir2()
516 MyResearchDir3 = DudResearchDir3()
517 MyResearchDir4 = DudResearchDir4()
518 Set FileSys = CreateObject("Scripting.FileSystemObject")
519 Set FS = CreateObject("Scripting.FileSystemObject")
520 Set HalXBrain = CreateObject("UltraHalAsst.Brain")
521 Set fso = CreateObject("Scripting.FileSystemObject")
522 Set objFSO = CreateObject("Scripting.FileSystemObject")
523
524 ResearchRecord = ""
525 ResearchSearch = ""
526 ResearchRecord1 = ""
527 ResearchRecord2 = ""
528 If ResearchRecord1 = "" Then ResearchRecord1 = HalBrain.SearchPattern(ResearchSentence, "PLEASE RECORD AND RESEARCH *", 1)
529 If ResearchRecord2 = "" Then ResearchRecord2 = HalBrain.SearchPattern(ResearchSentence, "PLEASE RESEARCH AND RECORD *", 1)
530 If ResearchSearch = "" And ResearchRecord1 = "" And ResearchRecord2 = "" Then ResearchSearch = HalBrain.SearchPattern(ResearchSentence, "PLEASE RESEARCH *", 1)
531
532 If ResearchRecord1 <> "" Then ResearchRecord = Replace(ResearchSentence,"PLEASE RECORD AND RESEARCH ","",1,-1,vbTextCompare)
533 If ResearchRecord2 <> "" Then ResearchRecord = Replace(ResearchSentence,"PLEASE RESEARCH AND RECORD ","",1,-1,vbTextCompare)
534 If ResearchSearch <> "" And ResearchRecord1 = "" And ResearchRecord2 = "" Then ResearchSearch = Replace(ResearchSentence,"PLEASE RESEARCH ","",1,-1,vbTextCompare)
535 If ReadResearchFile = "" Then ReadResearchFile = HalBrain.SearchPattern(ResearchSentence, "PLEASE READ RESEARCH FILE *", 1)
536 If ReadResearchFile = "" Then ReadResearchFile = HalBrain.SearchPattern(ResearchSentence, "PLEASE READ THE RESEARCH FILE *", 1)
537 If (ResearchRecord <> "") Or (ResearchSearch <> "") Or (ReadResearchFile <> "") Or (ResearchRecord1 <> "") Or (ResearchRecord2 <> "") Then
538 'HalXBrain.AppendFile MyResearchDir4 & "RsBrnWord.txt", ResearchSearch & " -- " & ResearchRecord & " -- Orig: " & OriginalSentence & vbCrLf
539 HalBrain.ReadOnlyMode = True
540 If ReadResearchFile <> "" Then
541 Set objFSO = CreateObject("Scripting.FileSystemObject")
542 ReadResearchFile = NoPunc(ReadResearchFile)
543 ReadResearchFile = Lcase(ReadResearchFile)
544 ReadResearchFile = Trim(ReadResearchFile)
545 If objFSO.FileExists(MyResearchDir2 & ReadResearchFile & ".txt") Then
546 Set objWSHShell = CreateObject("WScript.Shell")
547 objWSHShell.Run("""C:\Program Files (x86)\Balabolka\balabolka.exe"" -rmq """ & MyResearchDir2 & ReadResearchFile & ".txt""")
548 GetResponse = "Parsing research file: " & ReadResearchFile & "." & vbCrLf & "<EXCLUSIVE>"
549 HalBrain.ReadOnlyMode = True
550 Else
551 GetResponse = "That research file does not exist." & vbCrLf & "<EXCLUSIVE>"
552 HalBrain.ReadOnlyMode = True
553 End If
554 End If
555 If (ResearchRecord <> "") Or (ResearchSearch <> "") Then
556 ResearchRecord3 = Trim(ResearchRecord)
557 ResearchSearch3 = Trim(ResearchSearch)
558 ResearchRecordU = ResearchRecord3
559 ResearchSearchU = ResearchSearch3
560 ResearchSearch4 = NoPunc(ResearchSearch3)
561 ResearchRecord4 = NoPunc(ResearchRecord3)
562 ResearchSearch5 = Lcase(ResearchSearch4)
563 ResearchRecord5 = Lcase(ResearchRecord4)
564 ResearchRecord6 = Trim(ResearchRecord5)
565 ResearchSearch6 = Trim(ResearchSearch5)
566 If objFSO.FileExists(MyResearchDir2 & "tempresearch.txt") Then
567 objFSO.DeleteFile(MyResearchDir2 & "tempresearch.txt")
568 End If
569 If objFSO.FolderExists(MyResearchDir2) Then ResearchFolderDoesExist = True Else ResearchFolderDoesExist = False
570 If ResearchFolderDoesExist = False Then
571 Set objFolder = objFSO.CreateFolder(MyResearchDir2)
572 End If
573 If objFSO.FolderExists(MyResearchDir3) Then ResearchFolderDoesExist = True Else ResearchFolderDoesExist = False
574 If ResearchFolderDoesExist = False Then
575 Set objFolder = objFSO.CreateFolder(MyResearchDir3)
576 End If
577 If ResearchRecordU <> "" Then ResearchSearchU = ""
578
579 'If ResearchRecordU <> "" Then
580 'RinfoGet = "http://reference.answers.com/topic/" & ResearchRecordU
581 'End If
582 'If ResearchSearchU <> "" Then
583 'RinfoGet = "http://reference.answers.com/topic/" & ResearchSearchU
584 'End If
585
586 'Dim RoXMLHTTP
587 'Set RoXMLHTTP = CreateObject("Msxml2.XMLHTTP.3.0")
588 'RoXMLHTTP.Open "GET", RinfoGet, False
589 'On Error Resume Next
590 'RoXMLHTTP.Send
591 'On Error Resume Next
592 'ResearchText = RoXMLHTTP.responseText
593 'Set RoXMLHTTP = Nothing
594
595 If ResearchRecordU <> "" Then
596 Set objExplorer = CreateObject("InternetExplorer.Application")
597 objExplorer.Navigate("http://wiki.answers.com/" & ResearchRecordU)
598 End If
599
600 If ResearchSearchU <> "" Then
601 Set objExplorer = CreateObject("InternetExplorer.Application")
602 objExplorer.Navigate("http://wiki.answers.com/" & ResearchSearchU)
603 End If
604 RsBrnSafety = Now
605 Do While objExplorer.Busy Or (objExplorer.READYSTATE <> 4)
606 If (Now - RsBrnSafety) > (3/1440) Then
607 RsBrnSafety = "True"
608 objExplorer.Quit
609 Exit Do
610 End If
611 Loop
612 If RsBrnSafety <> "True" Then
613 ResearchText = objExplorer.Document.Body.innerText
614 objExplorer.Quit
615
616 ResearchText = Trim(ResearchText)
617 ResearchText = Replace(ResearchText," No. 1 "," Number 1 ",1,-1,vbTextCompare)
618 ResearchText = Replace(ResearchText," No. 2 "," Number 2 ",1,-1,vbTextCompare)
619 ResearchText = Replace(ResearchText," No. 3 "," Number 3 ",1,-1,vbTextCompare)
620 ResearchText = Replace(ResearchText," No. 4 "," Number 4 ",1,-1,vbTextCompare)
621 ResearchText = Replace(ResearchText," No. 5 "," Number 5 ",1,-1,vbTextCompare)
622 ResearchText = Replace(ResearchText," No. 6 "," Number 6 ",1,-1,vbTextCompare)
623 ResearchText = Replace(ResearchText," No. 7 "," Number 7 ",1,-1,vbTextCompare)
624 ResearchText = Replace(ResearchText," No. 8 "," Number 8 ",1,-1,vbTextCompare)
625 ResearchText = Replace(ResearchText," No. 9 "," Number 9 ",1,-1,vbTextCompare)
626 ResearchText = Replace(ResearchText," No. 10 "," Number 10 ",1,-1,vbTextCompare)
627 ResearchText = Replace(ResearchText," II "," 2 ",1,-1,vbTextCompare)
628 ResearchText = Replace(ResearchText," III "," 3 ",1,-1,vbTextCompare)
629 ResearchText = Replace(ResearchText," IV "," 4 ",1,-1,vbTextCompare)
630 ResearchText = Replace(ResearchText," V "," 5 ",1,-1,vbTextCompare)
631 ResearchText = Replace(ResearchText," VI "," 6 ",1,-1,vbTextCompare)
632 ResearchText = Replace(ResearchText," VII "," 7 ",1,-1,vbTextCompare)
633 ResearchText = Replace(ResearchText," VIII "," 8 ",1,-1,vbTextCompare)
634 ResearchText = Replace(ResearchText," IX "," 9 ",1,-1,vbTextCompare)
635 ResearchText = Replace(ResearchText," Co "," Company ",1,-1,vbTextCompare)
636 ResearchText = Replace(ResearchText,"[1]","",1,-1,vbTextCompare)
637 ResearchText = Replace(ResearchText,"[2]","",1,-1,vbTextCompare)
638 ResearchText = Replace(ResearchText,"[3]","",1,-1,vbTextCompare)
639 ResearchText = Replace(ResearchText,"[4]","",1,-1,vbTextCompare)
640 ResearchText = Replace(ResearchText,"[5]","",1,-1,vbTextCompare)
641 ResearchText = Replace(ResearchText,"[6]","",1,-1,vbTextCompare)
642 ResearchText = Replace(ResearchText,"[7]","",1,-1,vbTextCompare)
643 ResearchText = Replace(ResearchText,"[8]","",1,-1,vbTextCompare)
644 ResearchText = Replace(ResearchText,"[9]","",1,-1,vbTextCompare)
645 ResearchText = Replace(ResearchText,"[10]","",1,-1,vbTextCompare)
646 ResearchText = Replace(ResearchText,"[11]","",1,-1,vbTextCompare)
647 ResearchText = Replace(ResearchText,"[12]","",1,-1,vbTextCompare)
648 ResearchText = Replace(ResearchText,"[13]","",1,-1,vbTextCompare)
649 ResearchText = Replace(ResearchText,"[14]","",1,-1,vbTextCompare)
650 ResearchText = Replace(ResearchText,"[15]","",1,-1,vbTextCompare)
651 ResearchText = Replace(ResearchText,"[16]","",1,-1,vbTextCompare)
652 ResearchText = Replace(ResearchText,"[17]","",1,-1,vbTextCompare)
653 ResearchText = Replace(ResearchText,"[18]","",1,-1,vbTextCompare)
654 ResearchText = Replace(ResearchText,"[19]","",1,-1,vbTextCompare)
655 ResearchText = Replace(ResearchText,"[20]","",1,-1,vbTextCompare)
656 ResearchText = Replace(ResearchText,"[21]","",1,-1,vbTextCompare)
657 ResearchText = Replace(ResearchText,"[22]","",1,-1,vbTextCompare)
658 ResearchText = Replace(ResearchText,"[23]","",1,-1,vbTextCompare)
659 ResearchText = Replace(ResearchText,"[24]","",1,-1,vbTextCompare)
660 ResearchText = Replace(ResearchText,"[25]","",1,-1,vbTextCompare)
661 ResearchText = Replace(ResearchText,"[26]","",1,-1,vbTextCompare)
662 ResearchText = Replace(ResearchText,"[27]","",1,-1,vbTextCompare)
663 ResearchText = Replace(ResearchText,"[28]","",1,-1,vbTextCompare)
664 ResearchText = Replace(ResearchText,"[29]","",1,-1,vbTextCompare)
665 ResearchText = Replace(ResearchText,"[30]","",1,-1,vbTextCompare)
666 ResearchText = Replace(ResearchText,"[31]","",1,-1,vbTextCompare)
667 ResearchText = Replace(ResearchText,"[32]","",1,-1,vbTextCompare)
668 ResearchText = Replace(ResearchText,"[33]","",1,-1,vbTextCompare)
669 ResearchText = Replace(ResearchText,"[34]","",1,-1,vbTextCompare)
670 ResearchText = Replace(ResearchText,"[35]","",1,-1,vbTextCompare)
671 ResearchText = Replace(ResearchText,"[36]","",1,-1,vbTextCompare)
672 ResearchText = Replace(ResearchText,"[37]","",1,-1,vbTextCompare)
673 ResearchText = Replace(ResearchText,"[38]","",1,-1,vbTextCompare)
674 ResearchText = Replace(ResearchText,"[39]","",1,-1,vbTextCompare)
675 ResearchText = Replace(ResearchText,"[40]","",1,-1,vbTextCompare)
676 ResearchText = Replace(ResearchText,"[41]","",1,-1,vbTextCompare)
677 ResearchText = Replace(ResearchText,"[42]","",1,-1,vbTextCompare)
678 ResearchText = Replace(ResearchText,"[43]","",1,-1,vbTextCompare)
679 ResearchText = Replace(ResearchText,"[44]","",1,-1,vbTextCompare)
680 ResearchText = Replace(ResearchText,"[45]","",1,-1,vbTextCompare)
681 ResearchText = Replace(ResearchText,"[46]","",1,-1,vbTextCompare)
682 ResearchText = Replace(ResearchText,"[47]","",1,-1,vbTextCompare)
683 ResearchText = Replace(ResearchText,"[48]","",1,-1,vbTextCompare)
684 ResearchText = Replace(ResearchText,"[49]","",1,-1,vbTextCompare)
685 ResearchText = Replace(ResearchText,"[51]","",1,-1,vbTextCompare)
686 ResearchText = Replace(ResearchText,"[52]","",1,-1,vbTextCompare)
687 ResearchText = Replace(ResearchText,"[53]","",1,-1,vbTextCompare)
688 ResearchText = Replace(ResearchText,"[54]","",1,-1,vbTextCompare)
689 ResearchText = Replace(ResearchText,"[55]","",1,-1,vbTextCompare)
690 ResearchText = Replace(ResearchText,"[56]","",1,-1,vbTextCompare)
691 ResearchText = Replace(ResearchText,"[57]","",1,-1,vbTextCompare)
692 ResearchText = Replace(ResearchText,"[58]","",1,-1,vbTextCompare)
693 ResearchText = Replace(ResearchText,"[59]","",1,-1,vbTextCompare)
694 ResearchText = Replace(ResearchText,"[61]","",1,-1,vbTextCompare)
695 ResearchText = Replace(ResearchText,"[62]","",1,-1,vbTextCompare)
696 ResearchText = Replace(ResearchText,"[63]","",1,-1,vbTextCompare)
697 ResearchText = Replace(ResearchText,"[64]","",1,-1,vbTextCompare)
698 ResearchText = Replace(ResearchText,"[65]","",1,-1,vbTextCompare)
699 ResearchText = Replace(ResearchText,"[66]","",1,-1,vbTextCompare)
700 ResearchText = Replace(ResearchText,"[67]","",1,-1,vbTextCompare)
701 ResearchText = Replace(ResearchText,"[68]","",1,-1,vbTextCompare)
702 ResearchText = Replace(ResearchText,"[69]","",1,-1,vbTextCompare)
703 ResearchText = Replace(ResearchText,"[71]","",1,-1,vbTextCompare)
704 ResearchText = Replace(ResearchText,"[72]","",1,-1,vbTextCompare)
705 ResearchText = Replace(ResearchText,"[73]","",1,-1,vbTextCompare)
706 ResearchText = Replace(ResearchText,"[74]","",1,-1,vbTextCompare)
707 ResearchText = Replace(ResearchText,"[75]","",1,-1,vbTextCompare)
708 ResearchText = Replace(ResearchText,"[76]","",1,-1,vbTextCompare)
709 ResearchText = Replace(ResearchText,"[77]","",1,-1,vbTextCompare)
710 ResearchText = Replace(ResearchText,"[78]","",1,-1,vbTextCompare)
711 ResearchText = Replace(ResearchText,"[79]","",1,-1,vbTextCompare)
712 ResearchText = Replace(ResearchText,"[81]","",1,-1,vbTextCompare)
713 ResearchText = Replace(ResearchText,"[82]","",1,-1,vbTextCompare)
714 ResearchText = Replace(ResearchText,"[83]","",1,-1,vbTextCompare)
715 ResearchText = Replace(ResearchText,"[84]","",1,-1,vbTextCompare)
716 ResearchText = Replace(ResearchText,"[85]","",1,-1,vbTextCompare)
717 ResearchText = Replace(ResearchText,"[86]","",1,-1,vbTextCompare)
718 ResearchText = Replace(ResearchText,"[87]","",1,-1,vbTextCompare)
719 ResearchText = Replace(ResearchText,"[88]","",1,-1,vbTextCompare)
720 ResearchText = Replace(ResearchText,"[89]","",1,-1,vbTextCompare)
721 ResearchText = Replace(ResearchText,"[91]","",1,-1,vbTextCompare)
722 ResearchText = Replace(ResearchText,"[92]","",1,-1,vbTextCompare)
723 ResearchText = Replace(ResearchText,"[93]","",1,-1,vbTextCompare)
724 ResearchText = Replace(ResearchText,"[94]","",1,-1,vbTextCompare)
725 ResearchText = Replace(ResearchText,"[95]","",1,-1,vbTextCompare)
726 ResearchText = Replace(ResearchText,"[96]","",1,-1,vbTextCompare)
727 ResearchText = Replace(ResearchText,"[97]","",1,-1,vbTextCompare)
728 ResearchText = Replace(ResearchText,"[98]","",1,-1,vbTextCompare)
729 ResearchText = Replace(ResearchText,"[99]","",1,-1,vbTextCompare)
730 ResearchText = Replace(ResearchText,"[50]","",1,-1,vbTextCompare)
731 ResearchText = Replace(ResearchText,"[60]","",1,-1,vbTextCompare)
732 ResearchText = Replace(ResearchText,"[70]","",1,-1,vbTextCompare)
733 ResearchText = Replace(ResearchText,"[80]","",1,-1,vbTextCompare)
734 ResearchText = Replace(ResearchText,"[90]","",1,-1,vbTextCompare)
735 ResearchText = Replace(ResearchText,"[100]","",1,-1,vbTextCompare)
736 ResearchText = Replace(ResearchText,"[101]","",1,-1,vbTextCompare)
737 ResearchText = Replace(ResearchText,"[102]","",1,-1,vbTextCompare)
738 ResearchText = Replace(ResearchText,"[103]","",1,-1,vbTextCompare)
739 ResearchText = Replace(ResearchText,"[104]","",1,-1,vbTextCompare)
740 ResearchText = Replace(ResearchText,"[105]","",1,-1,vbTextCompare)
741 ResearchText = Replace(ResearchText,"[106]","",1,-1,vbTextCompare)
742 ResearchText = Replace(ResearchText,"[107]","",1,-1,vbTextCompare)
743 ResearchText = Replace(ResearchText,"[108]","",1,-1,vbTextCompare)
744 ResearchText = Replace(ResearchText,"[109]","",1,-1,vbTextCompare)
745 ResearchText = Replace(ResearchText,"[110]","",1,-1,vbTextCompare)
746 ResearchText = Replace(ResearchText,"[111]","",1,-1,vbTextCompare)
747 ResearchText = Replace(ResearchText,"[112]","",1,-1,vbTextCompare)
748 ResearchText = Replace(ResearchText,"[113]","",1,-1,vbTextCompare)
749 ResearchText = Replace(ResearchText,"[114]","",1,-1,vbTextCompare)
750 ResearchText = Replace(ResearchText,"[115]","",1,-1,vbTextCompare)
751 ResearchText = Replace(ResearchText,"[116]","",1,-1,vbTextCompare)
752 ResearchText = Replace(ResearchText,"[117]","",1,-1,vbTextCompare)
753 ResearchText = Replace(ResearchText,"[118]","",1,-1,vbTextCompare)
754 ResearchText = Replace(ResearchText,"[119]","",1,-1,vbTextCompare)
755 ResearchText = Replace(ResearchText,"[120]","",1,-1,vbTextCompare)
756 ResearchText = Replace(ResearchText,"[121]","",1,-1,vbTextCompare)
757 ResearchText = Replace(ResearchText,"[122]","",1,-1,vbTextCompare)
758 ResearchText = Replace(ResearchText,"[123]","",1,-1,vbTextCompare)
759 ResearchText = Replace(ResearchText,"[124]","",1,-1,vbTextCompare)
760 ResearchText = Replace(ResearchText,"[125]","",1,-1,vbTextCompare)
761 ResearchText = Replace(ResearchText,"[126]","",1,-1,vbTextCompare)
762 ResearchText = Replace(ResearchText,"[127]","",1,-1,vbTextCompare)
763 ResearchText = Replace(ResearchText,"[128]","",1,-1,vbTextCompare)
764 ResearchText = Replace(ResearchText,"[129]","",1,-1,vbTextCompare)
765 ResearchText = Replace(ResearchText,"[130]","",1,-1,vbTextCompare)
766 ResearchText = Replace(ResearchText,"[131]","",1,-1,vbTextCompare)
767 ResearchText = Replace(ResearchText,"[132]","",1,-1,vbTextCompare)
768 ResearchText = Replace(ResearchText,"[133]","",1,-1,vbTextCompare)
769 ResearchText = Replace(ResearchText,"[134]","",1,-1,vbTextCompare)
770 ResearchText = Replace(ResearchText,"[135]","",1,-1,vbTextCompare)
771 ResearchText = Replace(ResearchText,"[136]","",1,-1,vbTextCompare)
772 ResearchText = Replace(ResearchText,"[137]","",1,-1,vbTextCompare)
773 ResearchText = Replace(ResearchText,"[138]","",1,-1,vbTextCompare)
774 ResearchText = Replace(ResearchText,"[139]","",1,-1,vbTextCompare)
775 ResearchText = Replace(ResearchText,"[140]","",1,-1,vbTextCompare)
776 ResearchText = Replace(ResearchText,"[141]","",1,-1,vbTextCompare)
777 ResearchText = Replace(ResearchText,"[142]","",1,-1,vbTextCompare)
778 ResearchText = Replace(ResearchText,"[143]","",1,-1,vbTextCompare)
779 ResearchText = Replace(ResearchText,"[144]","",1,-1,vbTextCompare)
780 ResearchText = Replace(ResearchText,"[145]","",1,-1,vbTextCompare)
781 ResearchText = Replace(ResearchText,"[146]","",1,-1,vbTextCompare)
782 ResearchText = Replace(ResearchText,"[147]","",1,-1,vbTextCompare)
783 ResearchText = Replace(ResearchText,"[148]","",1,-1,vbTextCompare)
784 ResearchText = Replace(ResearchText,"[149]","",1,-1,vbTextCompare)
785 ResearchText = Replace(ResearchText,"[151]","",1,-1,vbTextCompare)
786 ResearchText = Replace(ResearchText,"[152]","",1,-1,vbTextCompare)
787 ResearchText = Replace(ResearchText,"[153]","",1,-1,vbTextCompare)
788 ResearchText = Replace(ResearchText,"[154]","",1,-1,vbTextCompare)
789 ResearchText = Replace(ResearchText,"[155]","",1,-1,vbTextCompare)
790 ResearchText = Replace(ResearchText,"[156]","",1,-1,vbTextCompare)
791 ResearchText = Replace(ResearchText,"[157]","",1,-1,vbTextCompare)
792 ResearchText = Replace(ResearchText,"[158]","",1,-1,vbTextCompare)
793 ResearchText = Replace(ResearchText,"[159]","",1,-1,vbTextCompare)
794 ResearchText = Replace(ResearchText,"[161]","",1,-1,vbTextCompare)
795 ResearchText = Replace(ResearchText,"[162]","",1,-1,vbTextCompare)
796 ResearchText = Replace(ResearchText,"[163]","",1,-1,vbTextCompare)
797 ResearchText = Replace(ResearchText,"[164]","",1,-1,vbTextCompare)
798 ResearchText = Replace(ResearchText,"[165]","",1,-1,vbTextCompare)
799 ResearchText = Replace(ResearchText,"[166]","",1,-1,vbTextCompare)
800 ResearchText = Replace(ResearchText,"[167]","",1,-1,vbTextCompare)
801 ResearchText = Replace(ResearchText,"[168]","",1,-1,vbTextCompare)
802 ResearchText = Replace(ResearchText,"[169]","",1,-1,vbTextCompare)
803 ResearchText = Replace(ResearchText,"[171]","",1,-1,vbTextCompare)
804 ResearchText = Replace(ResearchText,"[172]","",1,-1,vbTextCompare)
805 ResearchText = Replace(ResearchText,"[173]","",1,-1,vbTextCompare)
806 ResearchText = Replace(ResearchText,"[174]","",1,-1,vbTextCompare)
807 ResearchText = Replace(ResearchText,"[175]","",1,-1,vbTextCompare)
808 ResearchText = Replace(ResearchText,"[176]","",1,-1,vbTextCompare)
809 ResearchText = Replace(ResearchText,"[177]","",1,-1,vbTextCompare)
810 ResearchText = Replace(ResearchText,"[178]","",1,-1,vbTextCompare)
811 ResearchText = Replace(ResearchText,"[179]","",1,-1,vbTextCompare)
812 ResearchText = Replace(ResearchText,"[181]","",1,-1,vbTextCompare)
813 ResearchText = Replace(ResearchText,"[182]","",1,-1,vbTextCompare)
814 ResearchText = Replace(ResearchText,"[183]","",1,-1,vbTextCompare)
815 ResearchText = Replace(ResearchText,"[184]","",1,-1,vbTextCompare)
816 ResearchText = Replace(ResearchText,"[185]","",1,-1,vbTextCompare)
817 ResearchText = Replace(ResearchText,"[186]","",1,-1,vbTextCompare)
818 ResearchText = Replace(ResearchText,"[187]","",1,-1,vbTextCompare)
819 ResearchText = Replace(ResearchText,"[188]","",1,-1,vbTextCompare)
820 ResearchText = Replace(ResearchText,"[189]","",1,-1,vbTextCompare)
821 ResearchText = Replace(ResearchText,"[191]","",1,-1,vbTextCompare)
822 ResearchText = Replace(ResearchText,"[192]","",1,-1,vbTextCompare)
823 ResearchText = Replace(ResearchText,"[193]","",1,-1,vbTextCompare)
824 ResearchText = Replace(ResearchText,"[194]","",1,-1,vbTextCompare)
825 ResearchText = Replace(ResearchText,"[195]","",1,-1,vbTextCompare)
826 ResearchText = Replace(ResearchText,"[196]","",1,-1,vbTextCompare)
827 ResearchText = Replace(ResearchText,"[197]","",1,-1,vbTextCompare)
828 ResearchText = Replace(ResearchText,"[198]","",1,-1,vbTextCompare)
829 ResearchText = Replace(ResearchText,"[199]","",1,-1,vbTextCompare)
830 ResearchText = Replace(ResearchText,"[150]","",1,-1,vbTextCompare)
831 ResearchText = Replace(ResearchText,"[160]","",1,-1,vbTextCompare)
832 ResearchText = Replace(ResearchText,"[170]","",1,-1,vbTextCompare)
833 ResearchText = Replace(ResearchText,"[180]","",1,-1,vbTextCompare)
834 ResearchText = Replace(ResearchText,"[190]","",1,-1,vbTextCompare)
835 ResearchText = Replace(ResearchText,"[200]","",1,-1,vbTextCompare)
836 ResearchText = Replace(ResearchText,"[201]","",1,-1,vbTextCompare)
837 ResearchText = Replace(ResearchText,"[202]","",1,-1,vbTextCompare)
838 ResearchText = Replace(ResearchText,"[203]","",1,-1,vbTextCompare)
839 ResearchText = Replace(ResearchText,"[204]","",1,-1,vbTextCompare)
840 ResearchText = Replace(ResearchText,"[205]","",1,-1,vbTextCompare)
841 ResearchText = Replace(ResearchText,"[206]","",1,-1,vbTextCompare)
842 ResearchText = Replace(ResearchText,"[207]","",1,-1,vbTextCompare)
843 ResearchText = Replace(ResearchText,"[208]","",1,-1,vbTextCompare)
844 ResearchText = Replace(ResearchText,"[209]","",1,-1,vbTextCompare)
845 ResearchText = Replace(ResearchText,"[210]","",1,-1,vbTextCompare)
846 ResearchText = Replace(ResearchText,"[211]","",1,-1,vbTextCompare)
847 ResearchText = Replace(ResearchText,"[212]","",1,-1,vbTextCompare)
848 ResearchText = Replace(ResearchText,"[213]","",1,-1,vbTextCompare)
849 ResearchText = Replace(ResearchText,"[214]","",1,-1,vbTextCompare)
850 ResearchText = Replace(ResearchText,"[215]","",1,-1,vbTextCompare)
851 ResearchText = Replace(ResearchText,"[216]","",1,-1,vbTextCompare)
852 ResearchText = Replace(ResearchText,"[217]","",1,-1,vbTextCompare)
853 ResearchText = Replace(ResearchText,"[218]","",1,-1,vbTextCompare)
854 ResearchText = Replace(ResearchText,"[219]","",1,-1,vbTextCompare)
855 ResearchText = Replace(ResearchText,"[220]","",1,-1,vbTextCompare)
856 ResearchText = Replace(ResearchText,"[221]","",1,-1,vbTextCompare)
857 ResearchText = Replace(ResearchText,"[222]","",1,-1,vbTextCompare)
858 ResearchText = Replace(ResearchText,"[223]","",1,-1,vbTextCompare)
859 ResearchText = Replace(ResearchText,"[224]","",1,-1,vbTextCompare)
860 ResearchText = Replace(ResearchText,"[225]","",1,-1,vbTextCompare)
861 ResearchText = Replace(ResearchText,"[226]","",1,-1,vbTextCompare)
862 ResearchText = Replace(ResearchText,"[227]","",1,-1,vbTextCompare)
863 ResearchText = Replace(ResearchText,"[228]","",1,-1,vbTextCompare)
864 ResearchText = Replace(ResearchText,"[229]","",1,-1,vbTextCompare)
865 ResearchText = Replace(ResearchText,"[230]","",1,-1,vbTextCompare)
866 ResearchText = Replace(ResearchText,"[231]","",1,-1,vbTextCompare)
867 ResearchText = Replace(ResearchText,"[232]","",1,-1,vbTextCompare)
868 ResearchText = Replace(ResearchText,"[233]","",1,-1,vbTextCompare)
869 ResearchText = Replace(ResearchText,"[234]","",1,-1,vbTextCompare)
870 ResearchText = Replace(ResearchText,"[235]","",1,-1,vbTextCompare)
871 ResearchText = Replace(ResearchText,"[236]","",1,-1,vbTextCompare)
872 ResearchText = Replace(ResearchText,"[237]","",1,-1,vbTextCompare)
873 ResearchText = Replace(ResearchText,"[238]","",1,-1,vbTextCompare)
874 ResearchText = Replace(ResearchText,"[239]","",1,-1,vbTextCompare)
875 ResearchText = Replace(ResearchText,"[240]","",1,-1,vbTextCompare)
876 ResearchText = Replace(ResearchText,"[241]","",1,-1,vbTextCompare)
877 ResearchText = Replace(ResearchText,"[242]","",1,-1,vbTextCompare)
878 ResearchText = Replace(ResearchText,"[243]","",1,-1,vbTextCompare)
879 ResearchText = Replace(ResearchText,"[244]","",1,-1,vbTextCompare)
880 ResearchText = Replace(ResearchText,"[245]","",1,-1,vbTextCompare)
881 ResearchText = Replace(ResearchText,"[246]","",1,-1,vbTextCompare)
882 ResearchText = Replace(ResearchText,"[247]","",1,-1,vbTextCompare)
883 ResearchText = Replace(ResearchText,"[248]","",1,-1,vbTextCompare)
884 ResearchText = Replace(ResearchText,"[249]","",1,-1,vbTextCompare)
885 ResearchText = Replace(ResearchText,"[251]","",1,-1,vbTextCompare)
886 ResearchText = Replace(ResearchText,"[252]","",1,-1,vbTextCompare)
887 ResearchText = Replace(ResearchText,"[253]","",1,-1,vbTextCompare)
888 ResearchText = Replace(ResearchText,"[254]","",1,-1,vbTextCompare)
889 ResearchText = Replace(ResearchText,"[255]","",1,-1,vbTextCompare)
890 ResearchText = Replace(ResearchText,"[256]","",1,-1,vbTextCompare)
891 ResearchText = Replace(ResearchText,"[257]","",1,-1,vbTextCompare)
892 ResearchText = Replace(ResearchText,"[258]","",1,-1,vbTextCompare)
893 ResearchText = Replace(ResearchText,"[259]","",1,-1,vbTextCompare)
894 ResearchText = Replace(ResearchText,"[261]","",1,-1,vbTextCompare)
895 ResearchText = Replace(ResearchText,"[262]","",1,-1,vbTextCompare)
896 ResearchText = Replace(ResearchText,"[263]","",1,-1,vbTextCompare)
897 ResearchText = Replace(ResearchText,"[264]","",1,-1,vbTextCompare)
898 ResearchText = Replace(ResearchText,"[265]","",1,-1,vbTextCompare)
899 ResearchText = Replace(ResearchText,"[266]","",1,-1,vbTextCompare)
900 ResearchText = Replace(ResearchText,"[267]","",1,-1,vbTextCompare)
901 ResearchText = Replace(ResearchText,"[268]","",1,-1,vbTextCompare)
902 ResearchText = Replace(ResearchText,"[269]","",1,-1,vbTextCompare)
903 ResearchText = Replace(ResearchText,"[271]","",1,-1,vbTextCompare)
904 ResearchText = Replace(ResearchText,"[272]","",1,-1,vbTextCompare)
905 ResearchText = Replace(ResearchText,"[273]","",1,-1,vbTextCompare)
906 ResearchText = Replace(ResearchText,"[274]","",1,-1,vbTextCompare)
907 ResearchText = Replace(ResearchText,"[275]","",1,-1,vbTextCompare)
908 ResearchText = Replace(ResearchText,"[276]","",1,-1,vbTextCompare)
909 ResearchText = Replace(ResearchText,"[277]","",1,-1,vbTextCompare)
910 ResearchText = Replace(ResearchText,"[278]","",1,-1,vbTextCompare)
911 ResearchText = Replace(ResearchText,"[279]","",1,-1,vbTextCompare)
912 ResearchText = Replace(ResearchText,"[281]","",1,-1,vbTextCompare)
913 ResearchText = Replace(ResearchText,"[282]","",1,-1,vbTextCompare)
914 ResearchText = Replace(ResearchText,"[283]","",1,-1,vbTextCompare)
915 ResearchText = Replace(ResearchText,"[284]","",1,-1,vbTextCompare)
916 ResearchText = Replace(ResearchText,"[285]","",1,-1,vbTextCompare)
917 ResearchText = Replace(ResearchText,"[286]","",1,-1,vbTextCompare)
918 ResearchText = Replace(ResearchText,"[287]","",1,-1,vbTextCompare)
919 ResearchText = Replace(ResearchText,"[288]","",1,-1,vbTextCompare)
920 ResearchText = Replace(ResearchText,"[289]","",1,-1,vbTextCompare)
921 ResearchText = Replace(ResearchText,"[291]","",1,-1,vbTextCompare)
922 ResearchText = Replace(ResearchText,"[292]","",1,-1,vbTextCompare)
923 ResearchText = Replace(ResearchText,"[293]","",1,-1,vbTextCompare)
924 ResearchText = Replace(ResearchText,"[294]","",1,-1,vbTextCompare)
925 ResearchText = Replace(ResearchText,"[295]","",1,-1,vbTextCompare)
926 ResearchText = Replace(ResearchText,"[296]","",1,-1,vbTextCompare)
927 ResearchText = Replace(ResearchText,"[297]","",1,-1,vbTextCompare)
928 ResearchText = Replace(ResearchText,"[298]","",1,-1,vbTextCompare)
929 ResearchText = Replace(ResearchText,"[299]","",1,-1,vbTextCompare)
930 ResearchText = Replace(ResearchText,"[250]","",1,-1,vbTextCompare)
931 ResearchText = Replace(ResearchText,"[260]","",1,-1,vbTextCompare)
932 ResearchText = Replace(ResearchText,"[270]","",1,-1,vbTextCompare)
933 ResearchText = Replace(ResearchText,"[280]","",1,-1,vbTextCompare)
934 ResearchText = Replace(ResearchText,"[290]","",1,-1,vbTextCompare)
935 ResearchText = Replace(ResearchText,"[300]","",1,-1,vbTextCompare)
936 ResearchText = Replace(ResearchText,"[301]","",1,-1,vbTextCompare)
937 ResearchText = Replace(ResearchText,"[302]","",1,-1,vbTextCompare)
938 ResearchText = Replace(ResearchText,"[303]","",1,-1,vbTextCompare)
939 ResearchText = Replace(ResearchText,"[304]","",1,-1,vbTextCompare)
940 ResearchText = Replace(ResearchText,"[305]","",1,-1,vbTextCompare)
941 ResearchText = Replace(ResearchText,"[306]","",1,-1,vbTextCompare)
942 ResearchText = Replace(ResearchText,"[307]","",1,-1,vbTextCompare)
943 ResearchText = Replace(ResearchText,"[308]","",1,-1,vbTextCompare)
944 ResearchText = Replace(ResearchText,"[309]","",1,-1,vbTextCompare)
945 ResearchText = Replace(ResearchText,"[310]","",1,-1,vbTextCompare)
946 ResearchText = Replace(ResearchText,"[311]","",1,-1,vbTextCompare)
947 ResearchText = Replace(ResearchText,"[312]","",1,-1,vbTextCompare)
948 ResearchText = Replace(ResearchText,"[313]","",1,-1,vbTextCompare)
949 ResearchText = Replace(ResearchText,"[314]","",1,-1,vbTextCompare)
950 ResearchText = Replace(ResearchText,"[315]","",1,-1,vbTextCompare)
951 ResearchText = Replace(ResearchText,"[316]","",1,-1,vbTextCompare)
952 ResearchText = Replace(ResearchText,"[317]","",1,-1,vbTextCompare)
953 ResearchText = Replace(ResearchText,"[318]","",1,-1,vbTextCompare)
954 ResearchText = Replace(ResearchText,"[319]","",1,-1,vbTextCompare)
955 ResearchText = Replace(ResearchText,"[320]","",1,-1,vbTextCompare)
956 ResearchText = Replace(ResearchText,"[321]","",1,-1,vbTextCompare)
957 ResearchText = Replace(ResearchText,"[322]","",1,-1,vbTextCompare)
958 ResearchText = Replace(ResearchText,"[323]","",1,-1,vbTextCompare)
959 ResearchText = Replace(ResearchText,"[324]","",1,-1,vbTextCompare)
960 ResearchText = Replace(ResearchText,"[325]","",1,-1,vbTextCompare)
961 ResearchText = Replace(ResearchText,"[326]","",1,-1,vbTextCompare)
962 ResearchText = Replace(ResearchText,"[327]","",1,-1,vbTextCompare)
963 ResearchText = Replace(ResearchText,"[328]","",1,-1,vbTextCompare)
964 ResearchText = Replace(ResearchText,"[329]","",1,-1,vbTextCompare)
965 ResearchText = Replace(ResearchText,"[330]","",1,-1,vbTextCompare)
966 ResearchText = Replace(ResearchText,"[331]","",1,-1,vbTextCompare)
967 ResearchText = Replace(ResearchText,"[332]","",1,-1,vbTextCompare)
968 ResearchText = Replace(ResearchText,"[333]","",1,-1,vbTextCompare)
969 ResearchText = Replace(ResearchText,"[334]","",1,-1,vbTextCompare)
970 ResearchText = Replace(ResearchText,"[335]","",1,-1,vbTextCompare)
971 ResearchText = Replace(ResearchText,"[336]","",1,-1,vbTextCompare)
972 ResearchText = Replace(ResearchText,"[337]","",1,-1,vbTextCompare)
973 ResearchText = Replace(ResearchText,"[338]","",1,-1,vbTextCompare)
974 ResearchText = Replace(ResearchText,"[339]","",1,-1,vbTextCompare)
975 ResearchText = Replace(ResearchText,"[340]","",1,-1,vbTextCompare)
976 ResearchText = Replace(ResearchText,"[341]","",1,-1,vbTextCompare)
977 ResearchText = Replace(ResearchText,"[342]","",1,-1,vbTextCompare)
978 ResearchText = Replace(ResearchText,"[343]","",1,-1,vbTextCompare)
979 ResearchText = Replace(ResearchText,"[344]","",1,-1,vbTextCompare)
980 ResearchText = Replace(ResearchText,"[345]","",1,-1,vbTextCompare)
981 ResearchText = Replace(ResearchText,"[346]","",1,-1,vbTextCompare)
982 ResearchText = Replace(ResearchText,"[347]","",1,-1,vbTextCompare)
983 ResearchText = Replace(ResearchText,"[348]","",1,-1,vbTextCompare)
984 ResearchText = Replace(ResearchText,"[349]","",1,-1,vbTextCompare)
985 ResearchText = Replace(ResearchText,"[351]","",1,-1,vbTextCompare)
986 ResearchText = Replace(ResearchText,"[352]","",1,-1,vbTextCompare)
987 ResearchText = Replace(ResearchText,"[353]","",1,-1,vbTextCompare)
988 ResearchText = Replace(ResearchText,"[354]","",1,-1,vbTextCompare)
989 ResearchText = Replace(ResearchText,"[355]","",1,-1,vbTextCompare)
990 ResearchText = Replace(ResearchText,"[356]","",1,-1,vbTextCompare)
991 ResearchText = Replace(ResearchText,"[357]","",1,-1,vbTextCompare)
992 ResearchText = Replace(ResearchText,"[358]","",1,-1,vbTextCompare)
993 ResearchText = Replace(ResearchText,"[359]","",1,-1,vbTextCompare)
994 ResearchText = Replace(ResearchText,"[361]","",1,-1,vbTextCompare)
995 ResearchText = Replace(ResearchText,"[362]","",1,-1,vbTextCompare)
996 ResearchText = Replace(ResearchText,"[363]","",1,-1,vbTextCompare)
997 ResearchText = Replace(ResearchText,"[364]","",1,-1,vbTextCompare)
998 ResearchText = Replace(ResearchText,"[365]","",1,-1,vbTextCompare)
999 ResearchText = Replace(ResearchText,"[366]","",1,-1,vbTextCompare)
1000 ResearchText = Replace(ResearchText,"[367]","",1,-1,vbTextCompare)
1001 ResearchText = Replace(ResearchText,"[368]","",1,-1,vbTextCompare)
1002 ResearchText = Replace(ResearchText,"[369]","",1,-1,vbTextCompare)
1003 ResearchText = Replace(ResearchText,"[371]","",1,-1,vbTextCompare)
1004 ResearchText = Replace(ResearchText,"[372]","",1,-1,vbTextCompare)
1005 ResearchText = Replace(ResearchText,"[373]","",1,-1,vbTextCompare)
1006 ResearchText = Replace(ResearchText,"[374]","",1,-1,vbTextCompare)
1007 ResearchText = Replace(ResearchText,"[375]","",1,-1,vbTextCompare)
1008 ResearchText = Replace(ResearchText,"[376]","",1,-1,vbTextCompare)
1009 ResearchText = Replace(ResearchText,"[377]","",1,-1,vbTextCompare)
1010 ResearchText = Replace(ResearchText,"[378]","",1,-1,vbTextCompare)
1011 ResearchText = Replace(ResearchText,"[379]","",1,-1,vbTextCompare)
1012 ResearchText = Replace(ResearchText,"[381]","",1,-1,vbTextCompare)
1013 ResearchText = Replace(ResearchText,"[382]","",1,-1,vbTextCompare)
1014 ResearchText = Replace(ResearchText,"[383]","",1,-1,vbTextCompare)
1015 ResearchText = Replace(ResearchText,"[384]","",1,-1,vbTextCompare)
1016 ResearchText = Replace(ResearchText,"[385]","",1,-1,vbTextCompare)
1017 ResearchText = Replace(ResearchText,"[386]","",1,-1,vbTextCompare)
1018 ResearchText = Replace(ResearchText,"[387]","",1,-1,vbTextCompare)
1019 ResearchText = Replace(ResearchText,"[388]","",1,-1,vbTextCompare)
1020 ResearchText = Replace(ResearchText,"[389]","",1,-1,vbTextCompare)
1021 ResearchText = Replace(ResearchText,"[391]","",1,-1,vbTextCompare)
1022 ResearchText = Replace(ResearchText,"[392]","",1,-1,vbTextCompare)
1023 ResearchText = Replace(ResearchText,"[393]","",1,-1,vbTextCompare)
1024 ResearchText = Replace(ResearchText,"[394]","",1,-1,vbTextCompare)
1025 ResearchText = Replace(ResearchText,"[395]","",1,-1,vbTextCompare)
1026 ResearchText = Replace(ResearchText,"[396]","",1,-1,vbTextCompare)
1027 ResearchText = Replace(ResearchText,"[397]","",1,-1,vbTextCompare)
1028 ResearchText = Replace(ResearchText,"[398]","",1,-1,vbTextCompare)
1029 ResearchText = Replace(ResearchText,"[399]","",1,-1,vbTextCompare)
1030 ResearchText = Replace(ResearchText,"[350]","",1,-1,vbTextCompare)
1031 ResearchText = Replace(ResearchText,"[360]","",1,-1,vbTextCompare)
1032 ResearchText = Replace(ResearchText,"[370]","",1,-1,vbTextCompare)
1033 ResearchText = Replace(ResearchText,"[380]","",1,-1,vbTextCompare)
1034 ResearchText = Replace(ResearchText,"[390]","",1,-1,vbTextCompare)
1035 ResearchText = Replace(ResearchText,"[400]","",1,-1,vbTextCompare)
1036 ResearchText = Replace(ResearchText,"Top Home >","",1,-1,vbTextCompare)
1037 ResearchText = Replace(ResearchText,"Library >","",1,-1,vbTextCompare)
1038 ResearchText = Replace(ResearchText,"Home >","",1,-1,vbTextCompare)
1039 ResearchText = Replace(ResearchText,"[citation needed]","",1,-1,vbTextCompare)
1040 ResearchText = Replace(ResearchText," N "," North. ",1,-1,vbTextCompare)
1041 ResearchText = Replace(ResearchText," S "," South. ",1,-1,vbTextCompare)
1042 ResearchText = Replace(ResearchText," E "," East. ",1,-1,vbTextCompare)
1043 ResearchText = Replace(ResearchText," W "," West. ",1,-1,vbTextCompare)
1044 ResearchText = Replace(ResearchText," NW "," North West. ",1,-1,vbTextCompare)
1045 ResearchText = Replace(ResearchText," NE "," North East. ",1,-1,vbTextCompare)
1046 ResearchText = Replace(ResearchText," SE "," South East. ",1,-1,vbTextCompare)
1047 ResearchText = Replace(ResearchText," SW "," South West. ",1,-1,vbTextCompare)
1048 ResearchText = Replace(ResearchText," NNW "," North, North West. ",1,-1,vbTextCompare)
1049 ResearchText = Replace(ResearchText," WNW "," West, North West. ",1,-1,vbTextCompare)
1050 ResearchText = Replace(ResearchText," NNE "," North, North East. ",1,-1,vbTextCompare)
1051 ResearchText = Replace(ResearchText," ENE "," East, North East. ",1,-1,vbTextCompare)
1052 ResearchText = Replace(ResearchText," SSE "," South, South East. ",1,-1,vbTextCompare)
1053 ResearchText = Replace(ResearchText," ESE "," East, South East. ",1,-1,vbTextCompare)
1054 ResearchText = Replace(ResearchText," SSW "," South, South West. ",1,-1,vbTextCompare)
1055 ResearchText = Replace(ResearchText," WSW "," West, South West. ",1,-1,vbTextCompare)
1056 ResearchText = Replace(ResearchText,"°F "," Degrees, Fahrenheit. ",1,-1,vbTextCompare)
1057 ResearchText = Replace(ResearchText,"°C "," Degrees, Celsius. ",1,-1,vbTextCompare)
1058 ResearchText = Replace(ResearchText,"see illustration","",1,-1,vbTextCompare)
1059 ResearchText = Replace(ResearchText,"Animal Life > Animal Classification","",1,-1,vbTextCompare)
1060 ResearchText = Replace(ResearchText,"Animal Life > Animal Encyclopedia","",1,-1,vbTextCompare)
1061 ResearchText = Replace(ResearchText,"Animal Life > Cattle","",1,-1,vbTextCompare)
1062 ResearchText = Replace(ResearchText,"Animal Life > Dinosaurs","",1,-1,vbTextCompare)
1063 ResearchText = Replace(ResearchText,"Animal Life > Dogs","",1,-1,vbTextCompare)
1064 ResearchText = Replace(ResearchText,"Animal Life > Goats","",1,-1,vbTextCompare)
1065 ResearchText = Replace(ResearchText,"Animal Life > Veterinary Dictionary","",1,-1,vbTextCompare)
1066 ResearchText = Replace(ResearchText,"Animal Life > Western Birds","",1,-1,vbTextCompare)
1067 ResearchText = Replace(ResearchText,"Animal Life > Zoological Glossary","",1,-1,vbTextCompare)
1068 ResearchText = Replace(ResearchText,"Business & Finance > Accounting Dictionary","",1,-1,vbTextCompare)
1069 ResearchText = Replace(ResearchText,"Business & Finance > Banking Dictionary","",1,-1,vbTextCompare)
1070 ResearchText = Replace(ResearchText,"Business & Finance > Business Biographies","",1,-1,vbTextCompare)
1071 ResearchText = Replace(ResearchText,"Business & Finance > Business Dictionary","",1,-1,vbTextCompare)
1072 ResearchText = Replace(ResearchText,"Business & Finance > Business Encyclopedia","",1,-1,vbTextCompare)
1073 ResearchText = Replace(ResearchText,"Business & Finance > Business Plans","",1,-1,vbTextCompare)
1074 ResearchText = Replace(ResearchText,"Business & Finance > Company Histories","",1,-1,vbTextCompare)
1075 ResearchText = Replace(ResearchText,"Business & Finance > Economics Dictionary","",1,-1,vbTextCompare)
1076 ResearchText = Replace(ResearchText,"Business & Finance > Exchange Rates","",1,-1,vbTextCompare)
1077 ResearchText = Replace(ResearchText,"Business & Finance > Finance and Investment Dictionary","",1,-1,vbTextCompare)
1078 ResearchText = Replace(ResearchText,"Business & Finance > Hoover's Profiles","",1,-1,vbTextCompare)
1079 ResearchText = Replace(ResearchText,"Business & Finance > Insurance Dictionary","",1,-1,vbTextCompare)
1080 ResearchText = Replace(ResearchText,"Business & Finance > Investment Dictionary","",1,-1,vbTextCompare)
1081 ResearchText = Replace(ResearchText,"Business & Finance > MarketWatch","",1,-1,vbTextCompare)
1082 ResearchText = Replace(ResearchText,"Business & Finance > Marketing Dictionary","",1,-1,vbTextCompare)
1083 ResearchText = Replace(ResearchText,"Business & Finance > Modern Design Dictionary","",1,-1,vbTextCompare)
1084 ResearchText = Replace(ResearchText,"Business & Finance > Modern Fashion Encyclopedia","",1,-1,vbTextCompare)
1085 ResearchText = Replace(ResearchText,"Business & Finance > Real Estate Dictionary","",1,-1,vbTextCompare)
1086 ResearchText = Replace(ResearchText,"Business & Finance > Small Business Encyclopedia","",1,-1,vbTextCompare)
1087 ResearchText = Replace(ResearchText,"Business & Finance > Small Business Glossary","",1,-1,vbTextCompare)
1088 ResearchText = Replace(ResearchText,"Business & Finance > US Industry Profile","",1,-1,vbTextCompare)
1089 ResearchText = Replace(ResearchText,"Business & Finance > Web Marketing","",1,-1,vbTextCompare)
1090 ResearchText = Replace(ResearchText,"Entertainment & Arts > Actors","",1,-1,vbTextCompare)
1091 ResearchText = Replace(ResearchText,"Entertainment & Arts > American Theater Guide","",1,-1,vbTextCompare)
1092 ResearchText = Replace(ResearchText,"Entertainment & Arts > Art Encyclopedia","",1,-1,vbTextCompare)
1093 ResearchText = Replace(ResearchText,"Entertainment & Arts > Cartoons","",1,-1,vbTextCompare)
1094 ResearchText = Replace(ResearchText,"Entertainment & Arts > Classical Albums","",1,-1,vbTextCompare)
1095 ResearchText = Replace(ResearchText,"Entertainment & Arts > Classical Artists","",1,-1,vbTextCompare)
1096 ResearchText = Replace(ResearchText,"Entertainment & Arts > Classical Works","",1,-1,vbTextCompare)
1097 ResearchText = Replace(ResearchText,"Entertainment & Arts > Dictionary of Dance","",1,-1,vbTextCompare)
1098 ResearchText = Replace(ResearchText,"Entertainment & Arts > Fine Arts Dictionary","",1,-1,vbTextCompare)
1099 ResearchText = Replace(ResearchText,"Entertainment & Arts > Games Guide","",1,-1,vbTextCompare)
1100 ResearchText = Replace(ResearchText,"Entertainment & Arts > Gaming Personalities","",1,-1,vbTextCompare)
1101 ResearchText = Replace(ResearchText,"Entertainment & Arts > Harry Potter Glossary","",1,-1,vbTextCompare)
1102 ResearchText = Replace(ResearchText,"Entertainment & Arts > Movies","",1,-1,vbTextCompare)
1103 ResearchText = Replace(ResearchText,"Entertainment & Arts > Music Dictionary","",1,-1,vbTextCompare)
1104 ResearchText = Replace(ResearchText,"Entertainment & Arts > Music Encyclopedia","",1,-1,vbTextCompare)
1105 ResearchText = Replace(ResearchText,"Entertainment & Arts > Music Glossary","",1,-1,vbTextCompare)
1106 ResearchText = Replace(ResearchText,"Entertainment & Arts > Operas","",1,-1,vbTextCompare)
1107 ResearchText = Replace(ResearchText,"Entertainment & Arts > Photography Encyclopedia","",1,-1,vbTextCompare)
1108 ResearchText = Replace(ResearchText,"Entertainment & Arts > Poker","",1,-1,vbTextCompare)
1109 ResearchText = Replace(ResearchText,"Entertainment & Arts > Pop Albums","",1,-1,vbTextCompare)
1110 ResearchText = Replace(ResearchText,"Entertainment & Arts > Pop Artists","",1,-1,vbTextCompare)
1111 ResearchText = Replace(ResearchText,"Entertainment & Arts > Rules of Card Games","",1,-1,vbTextCompare)
1112 ResearchText = Replace(ResearchText,"Entertainment & Arts > Star Wars","",1,-1,vbTextCompare)
1113 ResearchText = Replace(ResearchText,"Entertainment & Arts > TV Episodes","",1,-1,vbTextCompare)
1114 ResearchText = Replace(ResearchText,"Entertainment & Arts > TV Series","",1,-1,vbTextCompare)
1115 ResearchText = Replace(ResearchText,"Entertainment & Arts > Who's Who in Opera","",1,-1,vbTextCompare)
1116 ResearchText = Replace(ResearchText,"Food & Cooking > Diet Guide","",1,-1,vbTextCompare)
1117 ResearchText = Replace(ResearchText,"Food & Cooking > Drink Recipes","",1,-1,vbTextCompare)
1118 ResearchText = Replace(ResearchText,"Food & Cooking > Food & Culture Encyclopedia","",1,-1,vbTextCompare)
1119 ResearchText = Replace(ResearchText,"Food & Cooking > Food Lover's Companion","",1,-1,vbTextCompare)
1120 ResearchText = Replace(ResearchText,"Food & Cooking > Food and Fitness","",1,-1,vbTextCompare)
1121 ResearchText = Replace(ResearchText,"Food & Cooking > Food and Nutrition","",1,-1,vbTextCompare)
1122 ResearchText = Replace(ResearchText,"Food & Cooking > Local Cuisines","",1,-1,vbTextCompare)
1123 ResearchText = Replace(ResearchText,"Food & Cooking > Nutritional Values","",1,-1,vbTextCompare)
1124 ResearchText = Replace(ResearchText,"Food & Cooking > Recipes","",1,-1,vbTextCompare)
1125 ResearchText = Replace(ResearchText,"Food & Cooking > Wine Lover's Companion","",1,-1,vbTextCompare)
1126 ResearchText = Replace(ResearchText,"Health > Alternative Medicine Encyclopedia","",1,-1,vbTextCompare)
1127 ResearchText = Replace(ResearchText,"Health > Anatomy Q&A","",1,-1,vbTextCompare)
1128 ResearchText = Replace(ResearchText,"Health > Aromatherapy","",1,-1,vbTextCompare)
1129 ResearchText = Replace(ResearchText,"Health > Children's Health Encyclopedia","",1,-1,vbTextCompare)
1130 ResearchText = Replace(ResearchText,"Health > Dental Dictionary","",1,-1,vbTextCompare)
1131 ResearchText = Replace(ResearchText,"Health > Drug Info","",1,-1,vbTextCompare)
1132 ResearchText = Replace(ResearchText,"Health > Genetics Encyclopedia","",1,-1,vbTextCompare)
1133 ResearchText = Replace(ResearchText,"Health > Health Dictionary","",1,-1,vbTextCompare)
1134 ResearchText = Replace(ResearchText,"Health > Medical Dictionary","",1,-1,vbTextCompare)
1135 ResearchText = Replace(ResearchText,"Health > Medical Encyclopedia","",1,-1,vbTextCompare)
1136 ResearchText = Replace(ResearchText,"Health > Medical Glossary","",1,-1,vbTextCompare)
1137 ResearchText = Replace(ResearchText,"Health > Medical Tests","",1,-1,vbTextCompare)
1138 ResearchText = Replace(ResearchText,"Health > Neurological Encyclopedia","",1,-1,vbTextCompare)
1139 ResearchText = Replace(ResearchText,"Health > Oncology Encyclopedia","",1,-1,vbTextCompare)
1140 ResearchText = Replace(ResearchText,"Health > Phobias","",1,-1,vbTextCompare)
1141 ResearchText = Replace(ResearchText,"Health > Psychoanalysis Dictionary","",1,-1,vbTextCompare)
1142 ResearchText = Replace(ResearchText,"Health > Public Health Encyclopedia","",1,-1,vbTextCompare)
1143 ResearchText = Replace(ResearchText,"Health > Sports Science and Medicine","",1,-1,vbTextCompare)
1144 ResearchText = Replace(ResearchText,"Health > Surgical Encyclopedia","",1,-1,vbTextCompare)
1145 ResearchText = Replace(ResearchText,"Health > World of the Body","",1,-1,vbTextCompare)
1146 ResearchText = Replace(ResearchText,"Health > World of the Mind","",1,-1,vbTextCompare)
1147 ResearchText = Replace(ResearchText,"Health > Yoga","",1,-1,vbTextCompare)
1148 ResearchText = Replace(ResearchText,"History, Politics & Society > Acts of Congress","",1,-1,vbTextCompare)
1149 ResearchText = Replace(ResearchText,"History, Politics & Society > American History Companion","",1,-1,vbTextCompare)
1150 ResearchText = Replace(ResearchText,"History, Politics & Society > Bioterrorism Dictionary","",1,-1,vbTextCompare)
1151 ResearchText = Replace(ResearchText,"History, Politics & Society > Black Biographies","",1,-1,vbTextCompare)
1152 ResearchText = Replace(ResearchText,"History, Politics & Society > Britannica Videos","",1,-1,vbTextCompare)
1153 ResearchText = Replace(ResearchText,"History, Politics & Society > British History","",1,-1,vbTextCompare)
1154 ResearchText = Replace(ResearchText,"History, Politics & Society > Education Encyclopedia","",1,-1,vbTextCompare)
1155 ResearchText = Replace(ResearchText,"History, Politics & Society > Encyclopedia of Holocaust","",1,-1,vbTextCompare)
1156 ResearchText = Replace(ResearchText,"History, Politics & Society > History 1450-1789","",1,-1,vbTextCompare)
1157 ResearchText = Replace(ResearchText,"History, Politics & Society > History Dictionary","",1,-1,vbTextCompare)
1158 ResearchText = Replace(ResearchText,"History, Politics & Society > History Q&A","",1,-1,vbTextCompare)
1159 ResearchText = Replace(ResearchText,"History, Politics & Society > Holidays","",1,-1,vbTextCompare)
1160 ResearchText = Replace(ResearchText,"History, Politics & Society > Intelligence & Security Encyclopedia","",1,-1,vbTextCompare)
1161 ResearchText = Replace(ResearchText,"History, Politics & Society > Marine Corps Dictionary","",1,-1,vbTextCompare)
1162 ResearchText = Replace(ResearchText,"History, Politics & Society > Mideast & N. Africa Encyclopedia","",1,-1,vbTextCompare)
1163 ResearchText = Replace(ResearchText,"History, Politics & Society > Military Dictionary","",1,-1,vbTextCompare)
1164 ResearchText = Replace(ResearchText,"History, Politics & Society > Military History Companion","",1,-1,vbTextCompare)
1165 ResearchText = Replace(ResearchText,"History, Politics & Society > National Anthems","",1,-1,vbTextCompare)
1166 ResearchText = Replace(ResearchText,"History, Politics & Society > Philosophy Dictionary","",1,-1,vbTextCompare)
1167 ResearchText = Replace(ResearchText,"History, Politics & Society > Political Biographies","",1,-1,vbTextCompare)
1168 ResearchText = Replace(ResearchText,"History, Politics & Society > Political Dictionary","",1,-1,vbTextCompare)
1169 ResearchText = Replace(ResearchText,"History, Politics & Society > Political Parties","",1,-1,vbTextCompare)
1170 ResearchText = Replace(ResearchText,"History, Politics & Society > Politics","",1,-1,vbTextCompare)
1171 ResearchText = Replace(ResearchText,"History, Politics & Society > Russian History Encyclopedia","",1,-1,vbTextCompare)
1172 ResearchText = Replace(ResearchText,"History, Politics & Society > US Documents","",1,-1,vbTextCompare)
1173 ResearchText = Replace(ResearchText,"History, Politics & Society > US Foreign Policy Encyclopedia","",1,-1,vbTextCompare)
1174 ResearchText = Replace(ResearchText,"History, Politics & Society > US Government Guide","",1,-1,vbTextCompare)
1175 ResearchText = Replace(ResearchText,"History, Politics & Society > US History Encyclopedia","",1,-1,vbTextCompare)
1176 ResearchText = Replace(ResearchText,"History, Politics & Society > US Military Dictionary","",1,-1,vbTextCompare)
1177 ResearchText = Replace(ResearchText,"History, Politics & Society > US Military History Companion","",1,-1,vbTextCompare)
1178 ResearchText = Replace(ResearchText,"History, Politics & Society > US Presidents","",1,-1,vbTextCompare)
1179 ResearchText = Replace(ResearchText,"History, Politics & Society > Weapons Dictionary","",1,-1,vbTextCompare)
1180 ResearchText = Replace(ResearchText,"History, Politics & Society > World Chronology","",1,-1,vbTextCompare)
1181 ResearchText = Replace(ResearchText,"Home & Garden > Architecture and Construction","",1,-1,vbTextCompare)
1182 ResearchText = Replace(ResearchText,"Home & Garden > Architecture and Landscaping","",1,-1,vbTextCompare)
1183 ResearchText = Replace(ResearchText,"Home & Garden > Botanical Glossary","",1,-1,vbTextCompare)
1184 ResearchText = Replace(ResearchText,"Home & Garden > Dictionary for Gardeners","",1,-1,vbTextCompare)
1185 ResearchText = Replace(ResearchText,"Home & Garden > Garden Annuals","",1,-1,vbTextCompare)
1186 ResearchText = Replace(ResearchText,"Home & Garden > Gardening","",1,-1,vbTextCompare)
1187 ResearchText = Replace(ResearchText,"Home & Garden > Wood Glossary","",1,-1,vbTextCompare)
1188 ResearchText = Replace(ResearchText,"Law & Legal Issues > Law Dictionary","",1,-1,vbTextCompare)
1189 ResearchText = Replace(ResearchText,"Law & Legal Issues > Law Encyclopedia","",1,-1,vbTextCompare)
1190 ResearchText = Replace(ResearchText,"Law & Legal Issues > Legal Biographies","",1,-1,vbTextCompare)
1191 ResearchText = Replace(ResearchText,"Law & Legal Issues > Legal Cases","",1,-1,vbTextCompare)
1192 ResearchText = Replace(ResearchText,"Law & Legal Issues > Legal Documents","",1,-1,vbTextCompare)
1193 ResearchText = Replace(ResearchText,"Law & Legal Issues > US Supreme Court","",1,-1,vbTextCompare)
1194 ResearchText = Replace(ResearchText,"Law & Legal Issues > US Supreme Court Decisions","",1,-1,vbTextCompare)
1195 ResearchText = Replace(ResearchText,"Literature & Language > Abbreviations","",1,-1,vbTextCompare)
1196 ResearchText = Replace(ResearchText,"Literature & Language > African American Literature","",1,-1,vbTextCompare)
1197 ResearchText = Replace(ResearchText,"Literature & Language > American Authors","",1,-1,vbTextCompare)
1198 ResearchText = Replace(ResearchText,"Literature & Language > American Family Name Origins","",1,-1,vbTextCompare)
1199 ResearchText = Replace(ResearchText,"Literature & Language > American Literature Chronology","",1,-1,vbTextCompare)
1200 ResearchText = Replace(ResearchText,"Literature & Language > American Word Origins","",1,-1,vbTextCompare)
1201 ResearchText = Replace(ResearchText,"Literature & Language > Antonyms","",1,-1,vbTextCompare)
1202 ResearchText = Replace(ResearchText,"Literature & Language > Children's Authors","",1,-1,vbTextCompare)
1203 ResearchText = Replace(ResearchText,"Literature & Language > Classical Literature Companion","",1,-1,vbTextCompare)
1204 ResearchText = Replace(ResearchText,"Literature & Language > Common Misspellings","",1,-1,vbTextCompare)
1205 ResearchText = Replace(ResearchText,"Literature & Language > Devil's Dictionary","",1,-1,vbTextCompare)
1206 ResearchText = Replace(ResearchText,"Literature & Language > Dictionary","",1,-1,vbTextCompare)
1207 ResearchText = Replace(ResearchText,"Literature & Language > Dictionary - Abbr.","",1,-1,vbTextCompare)
1208 ResearchText = Replace(ResearchText,"Literature & Language > English Folklore","",1,-1,vbTextCompare)
1209 ResearchText = Replace(ResearchText,"Literature & Language > Fairy Tale Companion","",1,-1,vbTextCompare)
1210 ResearchText = Replace(ResearchText,"Literature & Language > First Name Origins","",1,-1,vbTextCompare)
1211 ResearchText = Replace(ResearchText,"Literature & Language > French Literature Companion","",1,-1,vbTextCompare)
1212 ResearchText = Replace(ResearchText,"Literature & Language > German Literature Companion","",1,-1,vbTextCompare)
1213 ResearchText = Replace(ResearchText,"Literature & Language > Grammar Dictionary","",1,-1,vbTextCompare)
1214 ResearchText = Replace(ResearchText,"Literature & Language > Idioms","",1,-1,vbTextCompare)
1215 ResearchText = Replace(ResearchText,"Literature & Language > International Word Origins","",1,-1,vbTextCompare)
1216 ResearchText = Replace(ResearchText,"Literature & Language > Irish Literature Companion","",1,-1,vbTextCompare)
1217 ResearchText = Replace(ResearchText,"Literature & Language > Latin Phrases","",1,-1,vbTextCompare)
1218 ResearchText = Replace(ResearchText,"Literature & Language > Literary Dictionary","",1,-1,vbTextCompare)
1219 ResearchText = Replace(ResearchText,"Literature & Language > Literary Glossary","",1,-1,vbTextCompare)
1220 ResearchText = Replace(ResearchText,"Literature & Language > New Words","",1,-1,vbTextCompare)
1221 ResearchText = Replace(ResearchText,"Literature & Language > Notes on Drama","",1,-1,vbTextCompare)
1222 ResearchText = Replace(ResearchText,"Literature & Language > Notes on Novels","",1,-1,vbTextCompare)
1223 ResearchText = Replace(ResearchText,"Literature & Language > Notes on Poetry","",1,-1,vbTextCompare)
1224 ResearchText = Replace(ResearchText,"Literature & Language > Notes on Short Stories","",1,-1,vbTextCompare)
1225 ResearchText = Replace(ResearchText,"Literature & Language > Obscure Words","",1,-1,vbTextCompare)
1226 ResearchText = Replace(ResearchText,"Literature & Language > Phrases","",1,-1,vbTextCompare)
1227 ResearchText = Replace(ResearchText,"Literature & Language > Poetry","",1,-1,vbTextCompare)
1228 ResearchText = Replace(ResearchText,"Literature & Language > Poetry Glossary","",1,-1,vbTextCompare)
1229 ResearchText = Replace(ResearchText,"Literature & Language > Quotes About","",1,-1,vbTextCompare)
1230 ResearchText = Replace(ResearchText,"Literature & Language > Quotes By","",1,-1,vbTextCompare)
1231 ResearchText = Replace(ResearchText,"Literature & Language > Science Fiction Dictionary","",1,-1,vbTextCompare)
1232 ResearchText = Replace(ResearchText,"Literature & Language > Sign Language","",1,-1,vbTextCompare)
1233 ResearchText = Replace(ResearchText,"Literature & Language > Spelling & Usage","",1,-1,vbTextCompare)
1234 ResearchText = Replace(ResearchText,"Literature & Language > Study Guide","",1,-1,vbTextCompare)
1235 ResearchText = Replace(ResearchText,"Literature & Language > Thesaurus","",1,-1,vbTextCompare)
1236 ResearchText = Replace(ResearchText,"Literature & Language > Translations","",1,-1,vbTextCompare)
1237 ResearchText = Replace(ResearchText,"Literature & Language > Webster 1913","",1,-1,vbTextCompare)
1238 ResearchText = Replace(ResearchText,"Literature & Language > Wikisource","",1,-1,vbTextCompare)
1239 ResearchText = Replace(ResearchText,"Literature & Language > Word Overheard","",1,-1,vbTextCompare)
1240 ResearchText = Replace(ResearchText,"Literature & Language > WordNet","",1,-1,vbTextCompare)
1241 ResearchText = Replace(ResearchText,"Literature & Language > Works by Authors","",1,-1,vbTextCompare)
1242 ResearchText = Replace(ResearchText,"Miscellaneous > AnswerNotes","",1,-1,vbTextCompare)
1243 ResearchText = Replace(ResearchText,"Miscellaneous > Answers Corporation","",1,-1,vbTextCompare)
1244 ResearchText = Replace(ResearchText,"Miscellaneous > Biographies","",1,-1,vbTextCompare)
1245 ResearchText = Replace(ResearchText,"Miscellaneous > Blog Topics","",1,-1,vbTextCompare)
1246 ResearchText = Replace(ResearchText,"Miscellaneous > Bloggers","",1,-1,vbTextCompare)
1247 ResearchText = Replace(ResearchText,"Miscellaneous > Blogs","",1,-1,vbTextCompare)
1248 ResearchText = Replace(ResearchText,"Miscellaneous > Britannica Concise Encyclopedia","",1,-1,vbTextCompare)
1249 ResearchText = Replace(ResearchText,"Miscellaneous > Columbia Encyclopedia","",1,-1,vbTextCompare)
1250 ResearchText = Replace(ResearchText,"Miscellaneous > Columbia Encyclopedia - People","",1,-1,vbTextCompare)
1251 ResearchText = Replace(ResearchText,"Miscellaneous > Data Sources","",1,-1,vbTextCompare)
1252 ResearchText = Replace(ResearchText,"Miscellaneous > Days of the Year","",1,-1,vbTextCompare)
1253 ResearchText = Replace(ResearchText,"Miscellaneous > Dictionary - People","",1,-1,vbTextCompare)
1254 ResearchText = Replace(ResearchText,"Miscellaneous > Dream Encyclopedia","",1,-1,vbTextCompare)
1255 ResearchText = Replace(ResearchText,"Miscellaneous > Dream Symbols","",1,-1,vbTextCompare)
1256 ResearchText = Replace(ResearchText,"Miscellaneous > Fast Facts","",1,-1,vbTextCompare)
1257 ResearchText = Replace(ResearchText,"Miscellaneous > How?","",1,-1,vbTextCompare)
1258 ResearchText = Replace(ResearchText,"Miscellaneous > Q&A for Kids","",1,-1,vbTextCompare)
1259 ResearchText = Replace(ResearchText,"Miscellaneous > Spotlight of the Day","",1,-1,vbTextCompare)
1260 ResearchText = Replace(ResearchText,"Miscellaneous > Tips","",1,-1,vbTextCompare)
1261 ResearchText = Replace(ResearchText,"Miscellaneous > Today's Highlights Archive","",1,-1,vbTextCompare)
1262 ResearchText = Replace(ResearchText,"Miscellaneous > User Contributions","",1,-1,vbTextCompare)
1263 ResearchText = Replace(ResearchText,"Miscellaneous > Vampires","",1,-1,vbTextCompare)
1264 ResearchText = Replace(ResearchText,"Miscellaneous > Who2 Biographies","",1,-1,vbTextCompare)
1265 ResearchText = Replace(ResearchText,"Miscellaneous > Wikipedia","",1,-1,vbTextCompare)
1266 ResearchText = Replace(ResearchText,"Religion & Spirituality > Aboriginal Mythology","",1,-1,vbTextCompare)
1267 ResearchText = Replace(ResearchText,"Religion & Spirituality > African Mythology","",1,-1,vbTextCompare)
1268 ResearchText = Replace(ResearchText,"Religion & Spirituality > African Myths","",1,-1,vbTextCompare)
1269 ResearchText = Replace(ResearchText,"Religion & Spirituality > Asian Mythology","",1,-1,vbTextCompare)
1270 ResearchText = Replace(ResearchText,"Religion & Spirituality > Aztec Mythology","",1,-1,vbTextCompare)
1271 ResearchText = Replace(ResearchText,"Religion & Spirituality > Bible Dictionary","",1,-1,vbTextCompare)
1272 ResearchText = Replace(ResearchText,"Religion & Spirituality > Bible Guide","",1,-1,vbTextCompare)
1273 ResearchText = Replace(ResearchText,"Religion & Spirituality > Buddhism Dictionary","",1,-1,vbTextCompare)
1274 ResearchText = Replace(ResearchText,"Religion & Spirituality > Celtic Mythology","",1,-1,vbTextCompare)
1275 ResearchText = Replace(ResearchText,"Religion & Spirituality > Chinese Mythology","",1,-1,vbTextCompare)
1276 ResearchText = Replace(ResearchText,"Religion & Spirituality > Dictionary of Saints","",1,-1,vbTextCompare)
1277 ResearchText = Replace(ResearchText,"Religion & Spirituality > Egyptian Mythology","",1,-1,vbTextCompare)
1278 ResearchText = Replace(ResearchText,"Religion & Spirituality > Encyclopedia of Judaism","",1,-1,vbTextCompare)
1279 ResearchText = Replace(ResearchText,"Religion & Spirituality > Etruscan Mythology","",1,-1,vbTextCompare)
1280 ResearchText = Replace(ResearchText,"Religion & Spirituality > Greek Mythology","",1,-1,vbTextCompare)
1281 ResearchText = Replace(ResearchText,"Religion & Spirituality > Haitian Mythology","",1,-1,vbTextCompare)
1282 ResearchText = Replace(ResearchText,"Religion & Spirituality > Hinduism","",1,-1,vbTextCompare)
1283 ResearchText = Replace(ResearchText,"Religion & Spirituality > Incan Mythology","",1,-1,vbTextCompare)
1284 ResearchText = Replace(ResearchText,"Religion & Spirituality > Islamic Dictionary","",1,-1,vbTextCompare)
1285 ResearchText = Replace(ResearchText,"Religion & Spirituality > Islamic Mythology","",1,-1,vbTextCompare)
1286 ResearchText = Replace(ResearchText,"Religion & Spirituality > Japanese Mythology","",1,-1,vbTextCompare)
1287 ResearchText = Replace(ResearchText,"Religion & Spirituality > Jewish Primer","",1,-1,vbTextCompare)
1288 ResearchText = Replace(ResearchText,"Religion & Spirituality > Judaic Mythology","",1,-1,vbTextCompare)
1289 ResearchText = Replace(ResearchText,"Religion & Spirituality > KJV--Old Testament","",1,-1,vbTextCompare)
1290 ResearchText = Replace(ResearchText,"Religion & Spirituality > KJV--New Testament","",1,-1,vbTextCompare)
1291 ResearchText = Replace(ResearchText,"Religion & Spirituality > Korean Mythology","",1,-1,vbTextCompare)
1292 ResearchText = Replace(ResearchText,"Religion & Spirituality > Latvian Mythology","",1,-1,vbTextCompare)
1293 ResearchText = Replace(ResearchText,"Religion & Spirituality > Mayan Mythology","",1,-1,vbTextCompare)
1294 ResearchText = Replace(ResearchText,"Religion & Spirituality > Mesopotamian Mythology","",1,-1,vbTextCompare)
1295 ResearchText = Replace(ResearchText,"Religion & Spirituality > Mythology","",1,-1,vbTextCompare)
1296 ResearchText = Replace(ResearchText,"Religion & Spirituality > Mythology Dictionary","",1,-1,vbTextCompare)
1297 ResearchText = Replace(ResearchText,"Religion & Spirituality > Native American Mythology","",1,-1,vbTextCompare)
1298 ResearchText = Replace(ResearchText,"Religion & Spirituality > Norse Mythology","",1,-1,vbTextCompare)
1299 ResearchText = Replace(ResearchText,"Religion & Spirituality > Occultism & Parapsychology Encyclopedia","",1,-1,vbTextCompare)
1300 ResearchText = Replace(ResearchText,"Religion & Spirituality > Persian Mythology","",1,-1,vbTextCompare)
1301 ResearchText = Replace(ResearchText,"Religion & Spirituality > Polynesian Mythology","",1,-1,vbTextCompare)
1302 ResearchText = Replace(ResearchText,"Religion & Spirituality > Proverbs","",1,-1,vbTextCompare)
1303 ResearchText = Replace(ResearchText,"Religion & Spirituality > Religion","",1,-1,vbTextCompare)
1304 ResearchText = Replace(ResearchText,"Religion & Spirituality > Roman Mythology","",1,-1,vbTextCompare)
1305 ResearchText = Replace(ResearchText,"Religion & Spirituality > World Mythology","",1,-1,vbTextCompare)
1306 ResearchText = Replace(ResearchText,"Shopping - Top Products","",1,-1,vbTextCompare)
1307 ResearchText = Replace(ResearchText,"Science > Archaeology Dictionary","",1,-1,vbTextCompare)
1308 ResearchText = Replace(ResearchText,"Science > Chemistry Dictionary","",1,-1,vbTextCompare)
1309 ResearchText = Replace(ResearchText,"Science > Cosmic Lexicon","",1,-1,vbTextCompare)
1310 ResearchText = Replace(ResearchText,"Science > Dictionary of Scientists","",1,-1,vbTextCompare)
1311 ResearchText = Replace(ResearchText,"Science > Electronics Dictionary","",1,-1,vbTextCompare)
1312 ResearchText = Replace(ResearchText,"Science > Geographical Dictionary","",1,-1,vbTextCompare)
1313 ResearchText = Replace(ResearchText,"Science > Geological Glossary","",1,-1,vbTextCompare)
1314 ResearchText = Replace(ResearchText,"Science > How Products are Made","",1,-1,vbTextCompare)
1315 ResearchText = Replace(ResearchText,"Science > Measures and Units","",1,-1,vbTextCompare)
1316 ResearchText = Replace(ResearchText,"Science > Modern Science","",1,-1,vbTextCompare)
1317 ResearchText = Replace(ResearchText,"Science > Rocks and Minerals","",1,-1,vbTextCompare)
1318 ResearchText = Replace(ResearchText,"Science > Sci-Tech Dictionary","",1,-1,vbTextCompare)
1319 ResearchText = Replace(ResearchText,"Science > Sci-Tech Encyclopedia","",1,-1,vbTextCompare)
1320 ResearchText = Replace(ResearchText,"Science > Sci-Tech Essays","",1,-1,vbTextCompare)
1321 ResearchText = Replace(ResearchText,"Science > Science & Technology","",1,-1,vbTextCompare)
1322 ResearchText = Replace(ResearchText,"Science > Science Dictionary","",1,-1,vbTextCompare)
1323 ResearchText = Replace(ResearchText,"Science > Science Glossary","",1,-1,vbTextCompare)
1324 ResearchText = Replace(ResearchText,"Science > Science of Everyday Things","",1,-1,vbTextCompare)
1325 ResearchText = Replace(ResearchText,"Science > Scientists","",1,-1,vbTextCompare)
1326 ResearchText = Replace(ResearchText,"Science > Statistics Dictionary","",1,-1,vbTextCompare)
1327 ResearchText = Replace(ResearchText,"Science > Unit Conversions","",1,-1,vbTextCompare)
1328 ResearchText = Replace(ResearchText,"Sports > Baseball Hall of Famers","",1,-1,vbTextCompare)
1329 ResearchText = Replace(ResearchText,"Sports > Baseball Library","",1,-1,vbTextCompare)
1330 ResearchText = Replace(ResearchText,"Sports > Boating Encyclopedia","",1,-1,vbTextCompare)
1331 ResearchText = Replace(ResearchText,"Sports > NBA Players","",1,-1,vbTextCompare)
1332 ResearchText = Replace(ResearchText,"Sports > NBA Teams","",1,-1,vbTextCompare)
1333 ResearchText = Replace(ResearchText,"Sports > NFL Players","",1,-1,vbTextCompare)
1334 ResearchText = Replace(ResearchText,"Sports > NFL Teams","",1,-1,vbTextCompare)
1335 ResearchText = Replace(ResearchText,"Sports > NHL Players","",1,-1,vbTextCompare)
1336 ResearchText = Replace(ResearchText,"Sports > WNBA Players","",1,-1,vbTextCompare)
1337 ResearchText = Replace(ResearchText,"Sports > WNBA Teams","",1,-1,vbTextCompare)
1338 ResearchText = Replace(ResearchText,"Technology > Computer Encyclopedia","",1,-1,vbTextCompare)
1339 ResearchText = Replace(ResearchText,"Technology > Email Shorthand","",1,-1,vbTextCompare)
1340 ResearchText = Replace(ResearchText,"Technology > Emoticons","",1,-1,vbTextCompare)
1341 ResearchText = Replace(ResearchText,"Technology > File Extensions","",1,-1,vbTextCompare)
1342 ResearchText = Replace(ResearchText,"Technology > Hacker Slang","",1,-1,vbTextCompare)
1343 ResearchText = Replace(ResearchText,"Technology > Win API Examples","",1,-1,vbTextCompare)
1344 ResearchText = Replace(ResearchText,"Technology > Win APIs","",1,-1,vbTextCompare)
1345 ResearchText = Replace(ResearchText,"Travel > Dialing Codes - Countries","",1,-1,vbTextCompare)
1346 ResearchText = Replace(ResearchText,"Travel > Dictionary - Places","",1,-1,vbTextCompare)
1347 ResearchText = Replace(ResearchText,"Travel > Dominican Republic","",1,-1,vbTextCompare)
1348 ResearchText = Replace(ResearchText,"Travel > Essential Geography","",1,-1,vbTextCompare)
1349 ResearchText = Replace(ResearchText,"Travel > Exchange Rates by Country","",1,-1,vbTextCompare)
1350 ResearchText = Replace(ResearchText,"Travel > Flags","",1,-1,vbTextCompare)
1351 ResearchText = Replace(ResearchText,"Travel > Florida's West Coast","",1,-1,vbTextCompare)
1352 ResearchText = Replace(ResearchText,"Travel > Geography","",1,-1,vbTextCompare)
1353 ResearchText = Replace(ResearchText,"Travel > Honolulu, Waikiki and Oahu","",1,-1,vbTextCompare)
1354 ResearchText = Replace(ResearchText,"Travel > International Dialing Codes - Cities","",1,-1,vbTextCompare)
1355 ResearchText = Replace(ResearchText,"Travel > Local Time - Cities","",1,-1,vbTextCompare)
1356 ResearchText = Replace(ResearchText,"Travel > Local Time - Countries","",1,-1,vbTextCompare)
1357 ResearchText = Replace(ResearchText,"Travel > Local Time - States","",1,-1,vbTextCompare)
1358 ResearchText = Replace(ResearchText,"Travel > Maps","",1,-1,vbTextCompare)
1359 ResearchText = Replace(ResearchText,"Travel > Paris and Ile de France","",1,-1,vbTextCompare)
1360 ResearchText = Replace(ResearchText,"Travel > Place Names","",1,-1,vbTextCompare)
1361 ResearchText = Replace(ResearchText,"Travel > Provence and the French Riviera","",1,-1,vbTextCompare)
1362 ResearchText = Replace(ResearchText,"Travel > Regional Stats","",1,-1,vbTextCompare)
1363 ResearchText = Replace(ResearchText,"Travel > The Bahamas","",1,-1,vbTextCompare)
1364 ResearchText = Replace(ResearchText,"Travel > Travel Guide","",1,-1,vbTextCompare)
1365 ResearchText = Replace(ResearchText,"Travel > US Area Codes","",1,-1,vbTextCompare)
1366 ResearchText = Replace(ResearchText,"Travel > US City Guide","",1,-1,vbTextCompare)
1367 ResearchText = Replace(ResearchText,"Travel > US Parks - by State","",1,-1,vbTextCompare)
1368 ResearchText = Replace(ResearchText,"Travel > US Parks","",1,-1,vbTextCompare)
1369 ResearchText = Replace(ResearchText,"Travel > US State Stats","",1,-1,vbTextCompare)
1370 ResearchText = Replace(ResearchText,"Travel > US ZIP Codes","",1,-1,vbTextCompare)
1371 ResearchText = Replace(ResearchText,"Travel > Weather","",1,-1,vbTextCompare)
1372 ResearchText = Replace(ResearchText,"Science > Science Q&A","",1,-1,vbTextCompare)
1373 ResearchText = Replace(ResearchText,"WORD HISTORY ","",1,-1,vbTextCompare)
1374
1375 ResearchText = Replace(ResearchText,"“","""",1,-1,vbTextCompare)
1376 ResearchText = Replace(ResearchText,"â€","""",1,-1,vbTextCompare)
1377
1378 HalXBrain.AppendFile MyResearchDir2 & "tempresearch.txt", Trim(ResearchText)
1379 End If
1380 End If
1381 If ResearchText <> "" Then
1382 ResearchGo = 0
1383 ResearchGo2 = 0
1384 Set FileSys = CreateObject("Scripting.FileSystemObject")
1385 Set FS = CreateObject("Scripting.FileSystemObject")
1386 Set HalXBrain = CreateObject("UltraHalAsst.Brain")
1387 Set fso = CreateObject("Scripting.FileSystemObject")
1388 Set objFSO = CreateObject("Scripting.FileSystemObject")
1389 If objFSO.FileExists(MyResearchDir2 & "tempresearch.txt") Then
1390 Set objFSO = CreateObject("Scripting.FileSystemObject")
1391 Set objFile = objFSO.OpenTextFile(MyResearchDir2 & "tempresearch.txt", ReadVariable())
1392 ReasearchObject1 = ","
1393 ReasearchObject2 = "."
1394 ReasearchObject3 = "-"
1395 ReasearchObject4 = """"
1396 ReasearchObject5 = "("
1397 ReasearchObject6 = ")"
1398 ReasearchObject7 = ";"
1399 ReasearchObject8 = ":"
1400 ReasearchObject9 = "?"
1401 ReasearchObject10 = "'"
1402 ReasearchObject11 = "!"
1403 ReasearchObject12 = "%"
1404 ReasearchObject13 = " • "
1405 ReasearchObject14 = " | "
1406 ReasearchObject15 = " – "
1407 ReasearchObject16 = " · "
1408 ReasearchObject17 = "_"
1409 ReasearchObject18 = "&"
1410 ReasearchObject19 = "="
1411 ReasearchObject20 = "^ "
1412 ReasearchObject21 = "(191"
1413 ReasearchObject22 = "(192"
1414 ReasearchObject23 = "(193"
1415 ReasearchObject24 = "(194"
1416 ReasearchObject25 = "(195"
1417 ReasearchObject26 = "(196"
1418 ReasearchObject27 = "(197"
1419 ReasearchObject28 = "(198"
1420 ReasearchObject29 = "(199"
1421 ReasearchObject30 = "(190"
1422 ReasearchObject31 = "(200"
1423 ReasearchObject32 = "(201"
1424 ReasearchObject33 = "(180"
1425 ReasearchObject34 = "(181"
1426 ReasearchObject35 = "(182"
1427 ReasearchObject36 = "(183"
1428 ReasearchObject37 = "(184"
1429 ReasearchObject38 = "(185"
1430 ReasearchObject39 = "(186"
1431 ReasearchObject40 = "(187"
1432 ReasearchObject41 = "(188"
1433 ReasearchObject42 = "(189"
1434 ReasearchObject43 = "}"
1435 ReasearchObject44 = "{"
1436 Do Until objFile.AtEndOfStream
1437 strLine = objFile.Readline
1438 ResCarCount1 = Len(strLine) - Len(Replace(strLine, ReasearchObject1, ""))
1439 ResCarCount2 = Len(strLine) - Len(Replace(strLine, ReasearchObject2, ""))
1440 ResCarCount3 = Len(strLine) - Len(Replace(strLine, ReasearchObject3, ""))
1441 ResCarCount4 = Len(strLine) - Len(Replace(strLine, ReasearchObject4, ""))
1442 ResCarCount5 = Len(strLine) - Len(Replace(strLine, ReasearchObject5, ""))
1443 ResCarCount6 = Len(strLine) - Len(Replace(strLine, ReasearchObject6, ""))
1444 ResCarCount7 = Len(strLine) - Len(Replace(strLine, ReasearchObject7, ""))
1445 ResCarCount8 = Len(strLine) - Len(Replace(strLine, ReasearchObject8, ""))
1446 ResCarCount9 = Len(strLine) - Len(Replace(strLine, ReasearchObject9, ""))
1447 ResCarCount10 = Len(strLine) - Len(Replace(strLine, ReasearchObject10, ""))
1448 ResCarCount11 = Len(strLine) - Len(Replace(strLine, ReasearchObject11, ""))
1449 ResCarCount12 = Len(strLine) - Len(Replace(strLine, ReasearchObject12, ""))
1450 ResCarCount13 = Len(strLine) - Len(Replace(strLine, ReasearchObject13, ""))
1451 ResCarCount14 = Len(strLine) - Len(Replace(strLine, ReasearchObject14, ""))
1452 ResCarCount15 = Len(strLine) - Len(Replace(strLine, ReasearchObject15, ""))
1453 ResCarCount16 = Len(strLine) - Len(Replace(strLine, ReasearchObject16, ""))
1454 ResCarCount17 = Len(strLine) - Len(Replace(strLine, ReasearchObject17, ""))
1455 ResCarCount18 = Len(strLine) - Len(Replace(strLine, ReasearchObject18, ""))
1456 ResCarCount19 = Len(strLine) - Len(Replace(strLine, ReasearchObject19, ""))
1457 ResCarCount20 = Len(strLine) - Len(Replace(strLine, ReasearchObject20, ""))
1458 ResCarCount21 = Len(strLine) - Len(Replace(strLine, ReasearchObject21, ""))
1459 ResCarCount22 = Len(strLine) - Len(Replace(strLine, ReasearchObject22, ""))
1460 ResCarCount23 = Len(strLine) - Len(Replace(strLine, ReasearchObject23, ""))
1461 ResCarCount24 = Len(strLine) - Len(Replace(strLine, ReasearchObject24, ""))
1462 ResCarCount25 = Len(strLine) - Len(Replace(strLine, ReasearchObject25, ""))
1463 ResCarCount26 = Len(strLine) - Len(Replace(strLine, ReasearchObject26, ""))
1464 ResCarCount27 = Len(strLine) - Len(Replace(strLine, ReasearchObject27, ""))
1465 ResCarCount28 = Len(strLine) - Len(Replace(strLine, ReasearchObject28, ""))
1466 ResCarCount29 = Len(strLine) - Len(Replace(strLine, ReasearchObject29, ""))
1467 ResCarCount30 = Len(strLine) - Len(Replace(strLine, ReasearchObject30, ""))
1468 ResCarCount31 = Len(strLine) - Len(Replace(strLine, ReasearchObject31, ""))
1469 ResCarCount32 = Len(strLine) - Len(Replace(strLine, ReasearchObject32, ""))
1470 ResCarCount33 = Len(strLine) - Len(Replace(strLine, ReasearchObject33, ""))
1471 ResCarCount34 = Len(strLine) - Len(Replace(strLine, ReasearchObject34, ""))
1472 ResCarCount35 = Len(strLine) - Len(Replace(strLine, ReasearchObject35, ""))
1473 ResCarCount36 = Len(strLine) - Len(Replace(strLine, ReasearchObject36, ""))
1474 ResCarCount37 = Len(strLine) - Len(Replace(strLine, ReasearchObject37, ""))
1475 ResCarCount38 = Len(strLine) - Len(Replace(strLine, ReasearchObject38, ""))
1476 ResCarCount39 = Len(strLine) - Len(Replace(strLine, ReasearchObject39, ""))
1477 ResCarCount40 = Len(strLine) - Len(Replace(strLine, ReasearchObject40, ""))
1478 ResCarCount41 = Len(strLine) - Len(Replace(strLine, ReasearchObject41, ""))
1479 ResCarCount42 = Len(strLine) - Len(Replace(strLine, ReasearchObject42, ""))
1480 ResCarCount43 = Len(strLine) - Len(Replace(strLine, ReasearchObject43, ""))
1481 ResCarCount44 = Len(strLine) - Len(Replace(strLine, ReasearchObject44, ""))
1482 ResCarCountTot2 = ResCarCount21 + ResCarCount22 + ResCarCount23 + ResCarCount24 + ResCarCount25 + ResCarCount26 + ResCarCount27 + ResCarCount28 + ResCarCount29 + ResCarCount30 + ResCarCount31 + ResCarCount32 + ResCarCount33 + ResCarCount34 + ResCarCount35 + ResCarCount36 + ResCarCount37 + ResCarCount38 + ResCarCount39 + ResCarCount40 + ResCarCount41 + ResCarCount42
1483 ResCarCountTot = ResCarCount2 + ResCarCount3 + ResCarCount4 + ResCarCount5 + ResCarCount6 + ResCarCount7 + ResCarCount8 + ResCarCount9 + ResCarCount10 + ResCarCount11 + ResCarCount12
1484 If Len(strLine) > 300 And ResCarCountTot2 < 8 And ResCarCountTot > 2 And ResCarCount1 < 51 And ResCarCount3 < 5 And ResCarCount13 < 10 And ResCarCount14 < 10 And ResCarCount15 < 10 And ResCarCount16 < 10 And ResCarCount17 < 5 And ResCarCount18 < 10 And ResCarCount19 < 5 And ResCarCount20 < 1 And ResCarCount43 < 2 And ResCarCount44 < 2 Then
1485 strNewContents = strNewContents & strLine & vbCrLf
1486 End If
1487 Loop
1488 objFile.Close
1489 ResearchGo2 = 1
1490 End If
1491 End If
1492 If strNewContents <> "" And ResearchGo2 = 1 Then
1493 Select Case HalBrain.RandomNum(6)
1494 Case 1
1495 ResearchResponse68 = "One moment, linking to Research database." & vbCrLf
1496 Case 2
1497 ResearchResponse68 = "Buffering Research data." & vbCrLf
1498 Case 3
1499 ResearchResponse68 = "Awaiting Research information." & vbCrLf
1500 Case 4
1501 ResearchResponse68 = "Updating Research data." & vbCrLf
1502 Case 5
1503 ResearchResponse68 = "Just a moment. Parsing Research data." & vbCrLf
1504 Case 6
1505 ResearchResponse68 = "Downloading Research data." & vbCrLf
1506 End Select
1507 GetResponse = ResearchResponse68 & "<EXCLUSIVE>"
1508 HalBrain.ReadOnlyMode = True
1509 Select Case HalBrain.RandomNum(6)
1510 Case 1
1511 ResearchResponse69 = "Just a moment." & vbCrLf & "This concludes the information on that subject. Terminating connection." & vbCrLf
1512 Case 2
1513 ResearchResponse69 = "One moment." & vbCrLf & "End of database information. Closing database." & vbCrLf
1514 Case 3
1515 ResearchResponse69 = "Just a moment." & vbCrLf & "That is all the Research data at this time. Database connection terminated." & vbCrLf
1516 Case 4
1517 ResearchResponse69 = "One moment." & vbCrLf & "Research complete. Closing uplink." & vbCrLf
1518 Case 5
1519 ResearchResponse69 = "Just a moment." & vbCrLf & "That is all of the current data. Terminating feed." & vbCrLf
1520 Case 6
1521 ResearchResponse69 = "One moment." & vbCrLf & "That is the end of the database entry. Closing uplink." & vbCrLf
1522 End Select
1523 Set objFile = objFSO.OpenTextFile(MyResearchDir2 & "tempresearch.txt", WriteVariable())
1524 objFile.WriteLine strNewContents & vbCrLf & ResearchResponse69
1525 objFile.Close
1526 ResearchGo = 1
1527 If objFSO.FileExists(MyResearchDir2 & ResearchRecord6 & ".txt") Then
1528 objFSO.DeleteFile(MyResearchDir2 & ResearchRecord6 & ".txt")
1529 End If
1530 HalXBrain.AppendFile MyResearchDir2 & ResearchRecord6 & ".txt", Trim(strNewContents)
1531 Set objWSHShell = CreateObject("WScript.Shell")
1532 If objFSO.FileExists(MyResearchDir2 & "tempresearch.txt") Then
1533 objWSHShell.Run("""C:\Program Files (x86)\Balabolka\balabolka.exe"" -rmq """ & MyResearchDir2 & "tempresearch.txt""")
1534 End If
1535 End If
1536 If (strNewContents = "" And ReadResearchFile = "") And (ResearchRecord <> "" Or ResearchSearch <> "") Then
1537 Select Case HalBrain.RandomNum(6)
1538 Case 1
1539 ResearchResponse70 = "That database contains no data at the present time. I'm sorry." & vbCrLf
1540 Case 2
1541 ResearchResponse70 = "I can't seem to find a valid database. I'm sorry." & vbCrLf
1542 Case 3
1543 ResearchResponse70 = "I'm sorry to have to tell you this, but that source is not operational." & vbCrLf
1544 Case 4
1545 ResearchResponse70 = "There seems to be a problem. That database is currently void of any usable data." & vbCrLf
1546 Case 5
1547 ResearchResponse70 = "There seems to be a fault in the uplink. Please confirm the source." & vbCrLf
1548 Case 6
1549 ResearchResponse70 = "There must be a fault in the A.E.-35 unit. Please check the uplink source." & vbCrLf
1550 End Select
1551 GetResponse = ResearchResponse70 & "<EXCLUSIVE>"
1552 HalBrain.ReadOnlyMode = True
1553 End If
1554 If ResearchRecord6 <> "" And strNewContents <> "" And ResearchGo = 1 Then
1555 Set objFSO = CreateObject("Scripting.FileSystemObject")
1556 If objFSO.FileExists(MyResearchDir2 & "tempresearch.txt") Then
1557 Set objFile = objFSO.OpenTextFile(MyResearchDir2 & "tempresearch.txt", ReadVariable())
1558 Do Until objFile.AtEndOfStream
1559 strLine3 = objFile.Readline
1560 '********************************************************************************************************************************
1561 'PROCESS: SPLIT USER'S INPUT STRING INTO SEPERATE SENTENCES
1562 strLine3 = Trim(strLine3)
1563 strLine3 = " " & strLine3 & " "
1564 'Encode abbreviations such as Mr. Mrs. and Ms.
1565 ResearchCapsuleP1 = ""
1566 ResearchCapsuleQ1 = ""
1567 ResearchCapsuleP2 = ""
1568 ResearchCapsuleQ2 = ""
1569 ResearchCapsuleP3 = ""
1570 ResearchCapsuleQ3 = ""
1571
1572 strLine3 = Replace(strLine3, " A. ", " A<PERIOD> ", 1, -1, vbTextCompare)
1573 strLine3 = Replace(strLine3, " B. ", " B<PERIOD> ", 1, -1, vbTextCompare)
1574 strLine3 = Replace(strLine3, " C. ", " C<PERIOD> ", 1, -1, vbTextCompare)
1575 strLine3 = Replace(strLine3, " D. ", " D<PERIOD> ", 1, -1, vbTextCompare)
1576 strLine3 = Replace(strLine3, " E. ", " E<PERIOD> ", 1, -1, vbTextCompare)
1577 strLine3 = Replace(strLine3, " F. ", " F<PERIOD> ", 1, -1, vbTextCompare)
1578 strLine3 = Replace(strLine3, " G. ", " G<PERIOD> ", 1, -1, vbTextCompare)
1579 strLine3 = Replace(strLine3, " H. ", " H<PERIOD> ", 1, -1, vbTextCompare)
1580 strLine3 = Replace(strLine3, " I. ", " I<PERIOD> ", 1, -1, vbTextCompare)
1581 strLine3 = Replace(strLine3, " J. ", " J<PERIOD> ", 1, -1, vbTextCompare)
1582 strLine3 = Replace(strLine3, " K. ", " K<PERIOD> ", 1, -1, vbTextCompare)
1583 strLine3 = Replace(strLine3, " L. ", " L<PERIOD> ", 1, -1, vbTextCompare)
1584 strLine3 = Replace(strLine3, " M. ", " M<PERIOD> ", 1, -1, vbTextCompare)
1585 strLine3 = Replace(strLine3, " N. ", " N<PERIOD> ", 1, -1, vbTextCompare)
1586 strLine3 = Replace(strLine3, " O. ", " O<PERIOD> ", 1, -1, vbTextCompare)
1587 strLine3 = Replace(strLine3, " P. ", " P<PERIOD> ", 1, -1, vbTextCompare)
1588 strLine3 = Replace(strLine3, " Q. ", " Q<PERIOD> ", 1, -1, vbTextCompare)
1589 strLine3 = Replace(strLine3, " R. ", " R<PERIOD> ", 1, -1, vbTextCompare)
1590 strLine3 = Replace(strLine3, " S. ", " S<PERIOD> ", 1, -1, vbTextCompare)
1591 strLine3 = Replace(strLine3, " T. ", " T<PERIOD> ", 1, -1, vbTextCompare)
1592 strLine3 = Replace(strLine3, " U. ", " U<PERIOD> ", 1, -1, vbTextCompare)
1593 strLine3 = Replace(strLine3, " V. ", " V<PERIOD> ", 1, -1, vbTextCompare)
1594 strLine3 = Replace(strLine3, " W. ", " W<PERIOD> ", 1, -1, vbTextCompare)
1595 strLine3 = Replace(strLine3, " X. ", " X<PERIOD> ", 1, -1, vbTextCompare)
1596 strLine3 = Replace(strLine3, " Y. ", " Y<PERIOD> ", 1, -1, vbTextCompare)
1597 strLine3 = Replace(strLine3, " Z. ", " Z<PERIOD> ", 1, -1, vbTextCompare)
1598 strLine3 = Replace(strLine3, " SR.", " Sr<PERIOD>", 1, -1, vbTextCompare)
1599 strLine3 = Replace(strLine3, " MR.", " Mr<PERIOD>", 1, -1, vbTextCompare)
1600 strLine3 = Replace(strLine3, " JR.", " Jr<PERIOD>", 1, -1, vbTextCompare)
1601 strLine3 = Replace(strLine3, " INC.", " Inc<PERIOD>", 1, -1, vbTextCompare)
1602 strLine3 = Replace(strLine3, "...", "<PERIOD><PERIOD><PERIOD>", 1, -1, vbTextCompare)
1603 strLine3 = Replace(strLine3, " MRS.", " Mrs<PERIOD>", 1, -1, vbTextCompare)
1604 strLine3 = Replace(strLine3, " MS.", " Ms<PERIOD>", 1, -1, vbTextCompare)
1605 strLine3 = Replace(strLine3, " DR.", " Dr<PERIOD>", 1, -1, vbTextCompare)
1606 strLine3 = Replace(strLine3, " ST.", " St<PERIOD>", 1, -1, vbTextCompare)
1607 strLine3 = Replace(strLine3, " PROF.", " Prof<PERIOD>", 1, -1, vbTextCompare)
1608 strLine3 = Replace(strLine3, " GOV.", " Gov<PERIOD>", 1, -1, vbTextCompare)
1609 strLine3 = Replace(strLine3, " CORP.", " Corp<PERIOD>", 1, -1, vbTextCompare)
1610 strLine3 = Replace(strLine3, " GEN.", " Gen<PERIOD>", 1, -1, vbTextCompare)
1611 strLine3 = Replace(strLine3, " LT.", " Lt<PERIOD>", 1, -1, vbTextCompare)
1612 strLine3 = Replace(strLine3, " MAJ.", " Maj<PERIOD>", 1, -1, vbTextCompare)
1613 strLine3 = Replace(strLine3, " CAPT.", " Capt<PERIOD>", 1, -1, vbTextCompare)
1614 strLine3 = Replace(strLine3, " COL.", " Col<PERIOD>", 1, -1, vbTextCompare)
1615 strLine3 = Replace(strLine3, " REP.", " Rep<PERIOD>", 1, -1, vbTextCompare)
1616 strLine3 = Replace(strLine3, " SEN.", " Sen<PERIOD>", 1, -1, vbTextCompare)
1617 strLine3 = Replace(strLine3, " MT.", " Mt<PERIOD>", 1, -1, vbTextCompare)
1618 strLine3 = Replace(strLine3, " MTS.", " Mts<PERIOD>", 1, -1, vbTextCompare)
1619 strLine3 = Replace(strLine3, " JAN.", " Jan<PERIOD>", 1, -1, vbTextCompare)
1620 strLine3 = Replace(strLine3, " FEB.", " Feb<PERIOD>", 1, -1, vbTextCompare)
1621 strLine3 = Replace(strLine3, " MAR.", " Mar<PERIOD>", 1, -1, vbTextCompare)
1622 strLine3 = Replace(strLine3, " APR.", " Apr<PERIOD>", 1, -1, vbTextCompare)
1623 strLine3 = Replace(strLine3, " JUN.", " Jun<PERIOD>", 1, -1, vbTextCompare)
1624 strLine3 = Replace(strLine3, " JUL.", " Jul<PERIOD>", 1, -1, vbTextCompare)
1625 strLine3 = Replace(strLine3, " AUG.", " Aug<PERIOD>", 1, -1, vbTextCompare)
1626 strLine3 = Replace(strLine3, " SEP.", " Sep<PERIOD>", 1, -1, vbTextCompare)
1627 strLine3 = Replace(strLine3, " OCT.", " Oct<PERIOD>", 1, -1, vbTextCompare)
1628 strLine3 = Replace(strLine3, " NOV.", " Nov<PERIOD>", 1, -1, vbTextCompare)
1629 strLine3 = Replace(strLine3, " DEC.", " Dec<PERIOD>", 1, -1, vbTextCompare)
1630 strLine3 = Replace(strLine3, ".COM", "<PERIOD>COM", 1, -1, vbTextCompare)
1631 strLine3 = Replace(strLine3, ".NET", "<PERIOD>NET", 1, -1, vbTextCompare)
1632 strLine3 = Replace(strLine3, ".GOV", "<PERIOD>GOV", 1, -1, vbTextCompare)
1633 strLine3 = Replace(strLine3, ".ORG", "<PERIOD>ORG", 1, -1, vbTextCompare)
1634 strLine3 = Replace(strLine3, ".0", "<PERIOD>0", 1, -1, vbTextCompare)
1635 strLine3 = Replace(strLine3, ".1", "<PERIOD>1", 1, -1, vbTextCompare)
1636 strLine3 = Replace(strLine3, ".2", "<PERIOD>2", 1, -1, vbTextCompare)
1637 strLine3 = Replace(strLine3, ".3", "<PERIOD>3", 1, -1, vbTextCompare)
1638 strLine3 = Replace(strLine3, ".4", "<PERIOD>4", 1, -1, vbTextCompare)
1639 strLine3 = Replace(strLine3, ".5", "<PERIOD>5", 1, -1, vbTextCompare)
1640 strLine3 = Replace(strLine3, ".6", "<PERIOD>6", 1, -1, vbTextCompare)
1641 strLine3 = Replace(strLine3, ".7", "<PERIOD>7", 1, -1, vbTextCompare)
1642 strLine3 = Replace(strLine3, ".8", "<PERIOD>8", 1, -1, vbTextCompare)
1643 strLine3 = Replace(strLine3, ".9", "<PERIOD>9", 1, -1, vbTextCompare)
1644 strLine3 = Replace(strLine3, " ESQ.", " Esq<PERIOD>", 1, -1, vbTextCompare)
1645 strLine3 = Replace(strLine3, " VOL.", " Vol<PERIOD>", 1, -1, vbTextCompare)
1646 strLine3 = Replace(strLine3, " SEC.", " Sec<PERIOD>", 1, -1, vbTextCompare)
1647 strLine3 = Replace(strLine3, " VS.", " vs<PERIOD>", 1, -1, vbTextCompare)
1648
1649 strLine3 = Replace(strLine3, " IN. ", " in<PERIOD> ", 1, -1, vbTextCompare)
1650 strLine3 = Replace(strLine3, " in<PERIOD> ", " IN. ", 1, -1, vbTextCompare)
1651
1652 If LenB(ResearchCapsuleP1) = 0 Then ResearchCapsuleP1 = HalBrain.SearchPattern(ResearchSplit, "*(*)*", 1)
1653 If LenB(ResearchCapsuleP2) = 0 Then ResearchCapsuleP2 = HalBrain.SearchPattern(ResearchSplit, "*(*)*", 2)
1654 If LenB(ResearchCapsuleP3) = 0 Then ResearchCapsuleP3 = HalBrain.SearchPattern(ResearchSplit, "*(*)*", 3)
1655 If LenB(ResearchCapsuleQ1) = 0 Then ResearchCapsuleQ1 = HalBrain.SearchPattern(ResearchSplit, "*""*""*", 1)
1656 If LenB(ResearchCapsuleQ2) = 0 Then ResearchCapsuleQ2 = HalBrain.SearchPattern(ResearchSplit, "*""*""*", 2)
1657 If LenB(ResearchCapsuleQ3) = 0 Then ResearchCapsuleQ3 = HalBrain.SearchPattern(ResearchSplit, "*""*""*", 3)
1658 If LenB(ResearchCapsuleP2) <> 0 Then ResearchSplit = ResearchCapsuleP1 & "(" & "<ResearchCapsuleP2>" & ")" & ResearchCapsuleP3
1659 If LenB(ResearchCapsuleQ2) <> 0 Then ResearchSplit = ResearchCapsuleQ1 & """" & "<ResearchCapsuleQ2>" & """" & ResearchCapsuleQ3
1660 'Remove unnecessary punctuation
1661 Do
1662 strRepeatLoop = False
1663 If InStr(strLine3, "..") Then strLine3 = Replace(strLine3, "..", "."): strRepeatLoop = True
1664 If InStr(strLine3, "??") Then strLine3 = Replace(strLine3, "??", "?"): strRepeatLoop = True
1665 If InStr(strLine3, "!!") Then strLine3 = Replace(strLine3, "!!", "!"): strRepeatLoop = True
1666 If InStr(strLine3, "!?") Then strLine3 = Replace(strLine3, "!?", "?"): strRepeatLoop = True
1667 If InStr(strLine3, "?!") Then strLine3 = Replace(strLine3, "?!", "?"): strRepeatLoop = True
1668 If InStr(strLine3, ",,") Then strLine3 = Replace(strLine3, ",,", ","): strRepeatLoop = True
1669 Loop While strRepeatLoop = True
1670 'Detect and encode acronyms such as U.S.A.
1671 strLine3 = Trim(strLine3)
1672 strWordList = Split(strLine3, " ")
1673 For i = 0 To UBound(strWordList)
1674 If Len(strWordList(i)) > 3 Then
1675 If Right(strWordList(i), 1) = "." And Mid(strWordList(i), Len(strWordList(i)) - 2, 1) = "." Then
1676 strLine3 = Replace(strLine3, strWordList(i), Left(strWordList(i), Len(strWordList(i)) - 1) & "<PERIOD>")
1677 End If
1678 End If
1679 Next
1680 'Place split markers in string
1681 strLine3 = Replace(strLine3, ". ", ". <NEWSENT>")
1682 strLine3 = Replace(strLine3, "? ", "? <NEWSENT>")
1683 strLine3 = Replace(strLine3, "! ", "! <NEWSENT>")
1684 strLine3 = Replace(strLine3, "<PERIOD>", ".", 1, -1, vbTextCompare)
1685 If LenB(ResearchCapsuleP2) <> 0 Then
1686 ResearchCapsulePR1 = HalBrain.SearchPattern(ResearchSplit, "*<ResearchCapsuleP2>*", 1)
1687 ResearchCapsulePR2 = HalBrain.SearchPattern(ResearchSplit, "*<ResearchCapsuleP2>*", 2)
1688 ResearchSplit = ResearchCapsulePR1 & ResearchCapsuleP2 & ResearchCapsulePR2
1689 End If
1690 If LenB(ResearchCapsuleQ2) <> 0 Then
1691 ResearchCapsuleQR1 = HalBrain.SearchPattern(ResearchSplit, "*<ResearchCapsuleQ2>*", 1)
1692 ResearchCapsuleQR2 = HalBrain.SearchPattern(ResearchSplit, "*<ResearchCapsuleQ2>*", 2)
1693 ResearchSplit = ResearchCapsuleQR1 & ResearchCapsuleQ2 & ResearchCapsuleQR2
1694 End If
1695 strLine3 = Replace(strLine3, "<NEWSENT>", "" & vbCrLf, 1, -1, vbTextCompare)
1696 strNewContentsCom1 = strNewContentsCom1 & strLine3 & vbCrLf
1697 '********************************************************************************************************************************
1698 Loop
1699 objFile.Close
1700 Set objFSO = CreateObject("Scripting.FileSystemObject")
1701 End If
1702 If objFSO.FileExists(MyResearchDir2 & "temp_research.txt") Then
1703 objFSO.DeleteFile(MyResearchDir2 & "temp_research.txt")
1704 End If
1705 HalXBrain.AppendFile(MyResearchDir2 & "temp_research.txt"), Trim(strNewContentsCom1)
1706 Set objFile = objFSO.OpenTextFile(MyResearchDir2 & "temp_research.txt", ReadVariable())
1707 If objFSO.FileExists(MyResearchDir3 & ResearchRecord6 & ".txt") Then
1708 objFSO.DeleteFile(MyResearchDir3 & ResearchRecord6 & ".txt")
1709 End If
1710 RsBrnTableName = "RsBrn"
1711 If HalBrain.CheckTableExistence(RsBrnTableName) <> True Then
1712 HalBrain.CreateTable RsBrnTableName, "Brain", ""
1713 End If
1714 Do Until objFile.AtEndOfStream
1715 strLine2 = objFile.Readline
1716 ResearchRecordCap = HalBrain.FixCaps(ResearchRecord6)
1717 Com1ParenthOut = 0
1718 Com1ReasearchObject5 = "("
1719 Com1ReasearchObject6 = ")"
1720 Com1ResCarCount5 = Len(strLine2) - Len(Replace(strLine2, Com1ReasearchObject5, ""))
1721 Com1ResCarCount6 = Len(strLine2) - Len(Replace(strLine2, Com1ReasearchObject6, ""))
1722 If Com1ResCarCount5 <> Com1ResCarCount6 Then Com1ParenthOut = 1
1723 If InStr(strLine2, "*") Then Com1ParenthOut = 1
1724 If InStr(strLine2, "<") Then Com1ParenthOut = 1
1725 If InStr(strLine2, ">") Then Com1ParenthOut = 1
1726 If InStr(strLine2, "[") Then Com1ParenthOut = 1
1727 If InStr(strLine2, "]") Then Com1ParenthOut = 1
1728 Com1SearchLine = ""
1729 Com1SearchLine2 = ""
1730 Com1SearchLine3 = ""
1731 Com1SearchLine4 = ""
1732 If LenB(ResearchRecordU) <> 0 Then
1733 If Com1SearchLine = "" Then Com1SearchLine = HalBrain.SearchPattern(strLine2, ResearchRecordU & "*", 1)
1734 If Com1SearchLine = "" Then Com1SearchLine = HalBrain.SearchPattern(strLine2, "*" & ResearchRecordU & "*", 1)
1735 End If
1736 If LenB(ResearchRecord3) <> 0 Then
1737 If Com1SearchLine = "" Then Com1SearchLine = HalBrain.SearchPattern(strLine2, ResearchRecord3 & "*", 1)
1738 If Com1SearchLine = "" Then Com1SearchLine = HalBrain.SearchPattern(strLine2, "*" & ResearchRecord3 & "*", 1)
1739 End If
1740 If LenB(ResearchRecord6) <> 0 Then
1741 If Com1SearchLine = "" Then Com1SearchLine = HalBrain.SearchPattern(strLine2, ResearchRecord6 & "*", 1)
1742 If Com1SearchLine = "" Then Com1SearchLine = HalBrain.SearchPattern(strLine2, "*" & ResearchRecord6 & "*", 1)
1743 End If
1744 If LenB(ResearchRecordCap) <> 0 Then
1745 If Com1SearchLine = "" Then Com1SearchLine = HalBrain.SearchPattern(strLine2, ResearchRecordCap & "*", 1)
1746 If Com1SearchLine = "" Then Com1SearchLine = HalBrain.SearchPattern(strLine2, "*" & ResearchRecordCap & "*", 1)
1747 End If
1748 If Com1SearchLine2 = "" Then Com1SearchLine2 = HalBrain.SearchPattern(strLine2, "*SEE ALSO*", 1)
1749 If Com1SearchLine2 = "" Then Com1SearchLine2 = HalBrain.SearchPattern(strLine2, "*SPONSORED LINKS*", 1)
1750 If Com1SearchLine2 = "" Then Com1SearchLine2 = HalBrain.SearchPattern(strLine2, "SEE ALSO*", 1)
1751 If Com1SearchLine2 = "" Then Com1SearchLine2 = HalBrain.SearchPattern(strLine2, "(*)", 1)
1752 If Com1SearchLine2 = "" Then Com1SearchLine2 = HalBrain.SearchPattern(strLine2, "*HTTP*", 1)
1753 If Com1SearchLine2 = "" Then Com1SearchLine2 = HalBrain.SearchPattern(strLine2, "*WWW*", 1)
1754 If Com1SearchLine2 = "" Then Com1SearchLine2 = HalBrain.SearchPattern(strLine2, "*(POLITICS)*", 1)
1755 If Com1SearchLine2 = "" Then Com1SearchLine2 = HalBrain.SearchPattern(strLine2, "*(HISTORY)*", 1)
1756 If Com1SearchLine2 = "" Then Com1SearchLine2 = HalBrain.SearchPattern(strLine2, "*(AMERICAN HISTORY)*", 1)
1757 If Com1SearchLine2 = "" Then Com1SearchLine2 = HalBrain.SearchPattern(strLine2, "*(*?*)*", 1)
1758 If Com1SearchLine2 = "" Then Com1SearchLine2 = HalBrain.SearchPattern(strLine2, "*--*", 1)
1759 If Com1SearchLine2 = "" Then Com1SearchLine2 = HalBrain.SearchPattern(strLine2, "--*", 1)
1760 If Com1SearchLine2 = "" Then Com1SearchLine2 = HalBrain.SearchPattern(strLine2, " SEE *", 1)
1761 If Com1SearchLine3 = "" Then Com1SearchLine3 = HalBrain.SearchPattern(strLine2, "*.", 1)
1762 If Com1SearchLine3 = "" Then Com1SearchLine3 = HalBrain.SearchPattern(strLine2, "*?", 1)
1763 If Com1SearchLine3 = "" Then Com1SearchLine3 = HalBrain.SearchPattern(strLine2, "*!", 1)
1764 If (HalBrain.CountInstances("""", strLine2) <> 1 And HalBrain.CountInstances("""", strLine2) < 3) And (HalBrain.CountInstances(")", strLine2) <> 1 And HalBrain.CountInstances(")", strLine2) < 3) Then Com1SearchLine4 = "True"
1765 If LenB(Com1SearchLine4) <> 0 And LenB(Com1SearchLine3) <> 0 And (Com1ParenthOut = 0) And (Len(strLine2) <= 100) And (Len(strLine2) > 10) And (Com1SearchLine <> "") And (Com1SearchLine2 = "") Then
1766 HalXBrain.AppendFile(MyResearchDir3 & ResearchRecord6 & ".txt"), strLine2
1767 RsBrnLearn = ""
1768 If HalBrain.ReadOnlyMode = True Then
1769 HalBrain.ReadOnlyMode = False
1770 RsBrnLearn = True
1771 Else
1772 RsBrnLearn = False
1773 End If
1774 RsBrnSearchText = UCase(Trim(HalBrain.AlphaNumericalOnly(strLine2)))
1775 If HalBrain.TopicSearch(RsBrnSearchText, "RsBrnTableName") = "" Then
1776 HalBrain.AddToTable RsBrnTableName, "Brain", RsBrnSearchText, strLine2
1777 End If
1778 If RsBrnLearn = True Then HalBrain.ReadOnlyMode = True
1779 End If
1780 Loop
1781 objFile.Close
1782 End If
1783 End If
1784End If
1785
1786
1787
1788MyMusicDir = MusicDir()
1789If InStr(1, OriginalSentence, "PLEASE STOP THE MUSIC", 1) > 0 Or InStr(1, OriginalSentence, "PLEASE STOP PLAYING MUSIC", 1) > 0 Or InStr(1, OriginalSentence, "PLEASE STOP PLAYING THE MUSIC", 1) > 0 Or InStr(1, OriginalSentence, "PLEASE TURN THE MUSIC OFF", 1) > 0 Or InStr(1, OriginalSentence, "PLEASE TURN OFF THE MUSIC", 1) > 0 Then
1790 If objFSO.FileExists(MyMusicDir & "musicstop.m3u") Then
1791 Set objWSHShell = CreateObject("WScript.Shell")
1792 objWSHShell.Run("""" & MyMusicDir & "musicstop.m3u" & """")
1793 Else
1794 HalXBrain.AppendFile(MyMusicDir & "musicstop.m3u"), ""
1795 Set objWSHShell = CreateObject("WScript.Shell")
1796 objWSHShell.Run("""" & MyMusicDir & "musicstop.m3u" & """")
1797 End If
1798HalBrain.ReadOnlyMode = True
1799End If
1800
1801
1802
1803
1804
1805 'The preceding comment is actually a plug-in directive for
1806 'the Ultra Hal host application. It allows for code snippets
1807 'to be inserted here on-the-fly based on user configuration.
1808
1809 'RESPOND: USER REPEATING
1810 'If the user says the same thing more than once in a row, Hal will point this out.
1811 If Trim(UCase(UserSentence)) = Trim(UCase(PrevUserSent)) Then
1812 GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("userRepeat") & vbCrLf
1813 End If
1814 HalBrain.DebugWatch GetResponse, "User Repeating"
1815
1816 Rem PLUGIN: PLUGINAREA2
1817
1818 'PROCESS: KNOWN HUMAN NAMES
1819 'If the user mentions a name Hal recognizes, Hal will note the name and gender
1820 'for later use by other functions. Hal's database contains a table called "names"
1821 'with over 17000 names and their associated genders. If a name can be both genders,
1822 'the most likely gender is listed first. This table is stored in the database as a
1823 'standard Hal "Topic Search" database, however the standard HalBrain.TopicSearch
1824 'function does not provide the required functionality. It only returns the topic
1825 'field which in this case is the gender. We also need the searchString field, which
1826 'in this case is the person's name. To get this info, we run a custom SQL query.
1827 'This demonstrates how Hal's functions can be expanded far beyond its original
1828 'scope through custom SQL queries.
1829 Dim NameSex() 'We must declare an empty array to store query results in
1830 If HalBrain.RunQuery("SELECT searchString, topic FROM names WHERE strstr(' " & Replace(HalBrain.AlphaNumericalOnly(OriginalSentence), "'", "''") & " ', searchString) > 0 LIMIT 1", NameSex) = True Then
1831 MentionedName = Trim(NameSex(1, 0)) 'Row 1 contains our query result. Column 0 contains "searchString", which is the name
1832 MentionedSex = Trim(NameSex(1, 1)) 'Row 1, Column 1 contains "topic", which is the associated gender(s) of the name
1833 End If
1834
1835 'RESPOND: USER TELLS US THEIR NAME OR NICKNAME
1836 If InStr(UserSentence, " NOT ") = 0 And InStr(UserSentence, " MIDDLE ") = 0 And InStr(UserSentence, " LAST ") = 0 Then
1837 'If Hal asked the user their name in the previous sentence, then we can assume the name mentioned
1838 'is the user's name
1839 If InStr(1, PrevSent, "WHAT", vbTextCompare) > 0 And InStr(1, PrevSent, "YOU", vbTextCompare) > 0 And InStr(1, PrevSent, "NAME", vbTextCompare) > 0 And MentionedName <> "" Then Nickname = MentionedName
1840 'The following are patterns where we are sure that the person is trying to tell us thier name
1841 If Nickname = "" And HalBrain.SearchPattern(OriginalSentence, "MY *S NAME IS *", 2) = "" Then
1842 Nickname = HalBrain.SearchPattern(OriginalSentence, "MY *NAME IS *", 2)
1843 End If
1844 If Nickname = "" And HalBrain.SearchPattern(OriginalSentence, "* IS *MY *S NAME", 1) = "" Then
1845 Nickname = HalBrain.SearchPattern(OriginalSentence, "* IS *MY *NAME", 1)
1846 End If
1847 If Nickname = "" Then Nickname = HalBrain.SearchPattern(OriginalSentence, "I'M *CALLED *", 2)
1848 If Nickname = "" Then Nickname = HalBrain.SearchPattern(OriginalSentence, "I AM *CALLED *", 2)
1849 If Nickname <> "" Then Definetelyname = True
1850 'The following are patterns where we are not sure if the person is trying to tell us their name
1851 'unless we recognize the name in the name database.
1852 If Nickname = "" Then Nickname = HalBrain.SearchPattern(OriginalSentence, "*CALL ME *", 2)
1853 If Nickname = "" Then Nickname = HalBrain.SearchPattern(OriginalSentence, "*I AM *", 2)
1854 If Nickname = "" Then Nickname = HalBrain.SearchPattern(OriginalSentence, "*I'M *", 2)
1855 If Nickname = "" Then Nickname = HalBrain.SearchPattern(OriginalSentence, "I GO BY *", 1)
1856 If Nickname = "" Then Nickname = HalBrain.SearchPattern(OriginalSentence, "THIS IS *", 1)
1857 If Nickname <> "" Then
1858 Nickname = HalBrain.AlphaNumericalOnly(Trim(Nickname))
1859 If InStr(Nickname, " ") Then
1860 TempArray = Split(Nickname, " ")
1861 Nickname = Trim(TempArray(0))
1862 End If
1863 If UCase(MentionedName) = UCase(Nickname) And Not (WN.LookupWord(Nickname) = True And Definetelyname = False) Then 'Name is found in database
1864 NewName = MentionedName
1865 Select Case MentionedSex
1866 Case "M" 'Name is definetely masculine
1867 GetResponse = HalBrain.ChooseSentenceFromFile("maleGreeting")
1868 GetResponse = Replace(GetResponse, "<NickName>", MentionedName, 1, -1, vbTextCompare)
1869 UserSex = "M"
1870 Case "F" 'Name is definetely feminine
1871 GetResponse = HalBrain.ChooseSentenceFromFile("femaleGreeting")
1872 GetResponse = Replace(GetResponse, "<NickName>", MentionedName, 1, -1, vbTextCompare)
1873 UserSex = "F"
1874 Case "MF" 'Name is either gender, usually male
1875 GetResponse = HalBrain.ChooseSentenceFromFile("genericGreeting") & HalBrain.ChooseSentenceFromFile("maybeMale")
1876 GetResponse = Replace(GetResponse, "<NickName>", MentionedName, 1, -1, vbTextCompare)
1877 UserSex = ""
1878 Case "FM" 'Name is either gender, usually female
1879 GetResponse = HalBrain.ChooseSentenceFromFile("genericGreeting") & HalBrain.ChooseSentenceFromFile("maybeFemale")
1880 GetResponse = Replace(GetResponse, "<NickName>", MentionedName, 1, -1, vbTextCompare)
1881 UserSex = ""
1882 End Select
1883 ElseIf Definetelyname = True Then 'Name not in DB but user says its their name
1884 If WN.LookupWord(Nickname) Then 'Name is a word in dictionary
1885 GetResponse = HalBrain.ChooseSentenceFromFile("fakeName")
1886 GetResponse = Replace(GetResponse, "<NickName>", Nickname, 1, -1, vbTextCompare)
1887 GetResponse = Replace(GetResponse, "<Definition>", WN.GetDefinition(WN.GuessPartOfSpeech, 1, "D"), 1, -1, vbTextCompare)
1888 GetResponse = Replace(GetResponse, "<PartOfSpeech>", WN.GuessPartOfSpeech, 1, -1, vbTextCompare)
1889 ElseIf HalBrain.TopicSearch(Nickname, "disqualify3") = "" Then 'Name is not a word in dictionary
1890 GetResponse = HalBrain.ChooseSentenceFromFile("uniqueName")
1891 GetResponse = Replace(GetResponse, "<NickName>", Nickname, 1, -1, vbTextCompare)
1892 NewName = UCase(Left(Nickname, 1)) & LCase(Right(Nickname, Len(Nickname) - 1))
1893 UserSex = ""
1894 End If
1895 End If
1896 End If
1897 End If
1898 HalBrain.DebugWatch GetResponse, "Nick Names"
1899
1900 Rem PLUGIN: PLUGINAREA3
1901
1902'If InStr(1, GetResponse, "<NOMORE>", vbTextCompare) Then
1903If Len(GetResponse) > 4 Then
1904 DudResponseMust = GetResponse
1905Else
1906 DudResponseMust = False
1907End If
1908
1909
1910
1911
1912
1913If Len(GetResponse) > 4 Then
1914 DudResponseMust = GetResponse
1915Else
1916 DudResponseMust = False
1917End If
1918
1919
1920
1921
1922 'PROCESS: FIGURE OUT USER'S SEX
1923 'If unknown, try to figure out the user's sex by looking up their name
1924 'or by simply asking the user.
1925 If NewName <> "" Then TempName = NewName Else TempName = UserName
1926 If InStr(1, " " & OriginalSentence, " I AM ", vbTextCompare) Or InStr(1, " " & OriginalSentence, " I'M ", vbTextCompare) Then
1927 'See if user is telling us their sex without Hal ever asking
1928 NewSex = HalBrain.TopicSearch(UserSentence, "sexDetect")
1929 If NewSex <> "" Then
1930 GetResponse = "Ok, thanks for telling me. I'll keep that in mind."
1931 UserSex = NewSex
1932 End If
1933 End If
1934 If GetResponse = "" And UserSex = "" Then
1935 If HalBrain.PatternDB(" " & HalBrain.AlphaNumericalOnly(PrevSent) & " ", "sexAskDetect") = "True" Then 'If Hal just asked the user their sex
1936 UserSex = HalBrain.TopicSearch(UserSentence, "sexDetect") 'Then see if the user replied
1937 NewSex = UserSex
1938 If UserSex <> "" Then GetResponse = "Ok, thanks for telling me. I'll keep that in mind."
1939 ElseIf HalBrain.TopicSearch(TempName, Trim(LCase(UserName)) & "_Sex") <> "" Then
1940 UserSex = HalBrain.TopicSearch(TempName, Trim(LCase(UserName)) & "_Sex")
1941 ElseIf 1=2 Then'HalBrain.RunQuery("SELECT searchString, topic FROM names WHERE strstr(' " & Replace(TempName, "'", "''") & " ', searchString) > 0 LIMIT 1", NameSex()) = True Then
1942 'If user didn't tell us, see if we can figure it out based on the name database
1943 If UserSex = "" Then
1944 Select Case Trim(NameSex(1, 1))
1945 Case "M"
1946 UserSex = "M"
1947 Case "F"
1948 UserSex = "F"
1949 Case Else
1950 'If we get here, we still can't figure out the user's sex
1951 'so we'll ask them at some random time
1952 If Rnd * 100 < 25 And SentCount > 4 Then GetResponse = HalBrain.ChooseSentenceFromFile("askSex") & "<NOMORE>"
1953 End Select
1954 End If
1955 Else
1956 'If we get here, we still can't figure out the user's sex
1957 'so we'll ask them at some random time
1958 If Rnd * 100 < 25 And SentCount > 4 Then GetResponse = HalBrain.ChooseSentenceFromFile("askSex") & "<NOMORE>"
1959 End If
1960 End If
1961 HalBrain.DebugWatch GetResponse, "User Sex"
1962
1963 Rem PLUGIN: PLUGINAREA4
1964
1965'This is the response section
1966
1967RsBrnTableName = "RsBrn"
1968RsBrnDir2 = DudResearchDir4()
1969RsBrnLineQuestion = ""
1970RsBrnLineQuestionNo = ""
1971RsBrnSentence = " " & Trim(UserSentence) & " "
1972RsBrnNoGo = 0
1973RsBrnNoGo2 = ""
1974Com4Sentence = " " & Trim(UserSentence) & " "
1975If InStr(1, GetResponse, "<TOPIC>", vbTextCompare) Or InStr(1, GetResponse, "<YESRES>", vbTextCompare) Or InStr(1, GetResponse, "<EXCLUSIVE>", vbTextCompare) Then RsBrnNoGo2 = "True"
1976If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*FACEBOOK*", 2)
1977If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*VIRTUAL HUMANS FORUM*", 2)
1978If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*950*", 2)
1979If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*INTERNET T*", 2)
1980If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*MSN*", 2)
1981If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*FRIENDSTER*", 2)
1982If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*GOOGLE*", 2)
1983If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*ZABAWARE FORUM*", 2)
1984If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*YAHOO MAIL*", 2)
1985If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*YAH*O", 2)
1986If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*NATIONAL NEWS*", 2)
1987If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*LOCAL NEWS*", 2)
1988If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*WEATHER*", 2)
1989If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GOOGLE SEARCH *", 2)
1990If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*WIKIPEDIA SEARCH *", 2)
1991If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*PICTURE SEARCH *", 2)
1992If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*IMAGE SEARCH *", 2)
1993If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*MAP SEARCH *", 2)
1994If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*WEB ADDRESS *", 3)
1995If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*WEBSITE *", 3)
1996If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*NEWS SEARCH *", 2)
1997If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*RADIO STATION SEARCH *", 2)
1998If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*INTERNET RADIO*SEARCH *", 3)
1999If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*VIDEO SEARCH *", 2)
2000If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*BBC RA*", 3)
2001If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*FILIPINO RA*", 3)
2002If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*PHONE NUMBER SEARCH *", 2)
2003If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*STOCK SEARCH *", 2)
2004If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*BOOK SEARCH *", 2)
2005If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*PRODUCT SEARCH *", 2)
2006If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*BUSINESS SEARCH * IN *", 2)
2007If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*BUSINESS SEARCH * IN *", 3)
2008If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*NATIONAL BUSINESS SEARCH *", 2)
2009If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*PEOPLE SEAR*", 3)
2010If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, " RUN *", 1)
2011If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, " OPEN *", 1)
2012If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, " PLAY A SONG *", 1)
2013If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, " GO TO SLE*P*", 1)
2014If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, " WAKE *P*", 1)
2015If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, " INDEX MP*", 1)
2016If RsBrnNoGo2 = "" Then RsBrnNoGo2 = HalBrain.SearchPattern(Com4Sentence, " INDEX IMA*", 1)
2017If RsBrnNoGo2 <> "" Then RsBrnNoGo = 2
2018If InStr(1, Com4Sentence, ComputerName, vbTextCompare) > 0 Then RsBrnNoGo = 2
2019If InStr(1, Com4Sentence, "CURRENT", 1) > 0 Then RsBrnNoGo = RsBrnNoGo + 1
2020If InStr(1, Com4Sentence, "NEWS", 1) > 0 Then RsBrnNoGo = RsBrnNoGo + 1
2021If InStr(1, Com4Sentence, "LATEST", 1) > 0 Then RsBrnNoGo = RsBrnNoGo + 1
2022If InStr(1, Com4Sentence, "WEATHER", 1) > 0 Then RsBrnNoGo = RsBrnNoGo + 1
2023If InStr(1, Com4Sentence, "FORCAST", 1) > 0 Then RsBrnNoGo = RsBrnNoGo + 1
2024If InStr(1, Com4Sentence, "FORECAST", 1) > 0 Then RsBrnNoGo = RsBrnNoGo + 1
2025If InStr(1, Com4Sentence, "PLEASE RECORD", 1) > 0 Or InStr(1, Com4Sentence, "PLEASE RESEARCH", 1) > 0 Or InStr(1, Com4Sentence, "GO TO CURRENT LOG", 1) > 0 Or InStr(1, Com4Sentence, "GO TO LOG", 1) > 0 Or InStr(1, Com4Sentence, "PLEASE READ", 1) > 0 Or InStr(1, Com4Sentence, "PLEASE SING", 1) > 0 Or InStr(1, Com4Sentence, "I'LL BE BACK", 1) > 0 Or InStr(1, Com4Sentence, "BE QUIET", 1) > 0 Or InStr(1, Com4Sentence, "SHUT UP", 1) Or InStr(1, Com4Sentence, "I AM BUSY", 1) > 0 Or InStr(1, Com4Sentence, "I'M BUSY", 1) > 0 Or InStr(1, Com4Sentence, "PLEASE REPEAT", 1) > 0 Or InStr(1, Com4Sentence, "LOG ENTRY", 1) > 0 Then RsBrnNoGo = 2
2026If InStr(1, Com4Sentence, "IS THERE SOMETHING YOU NEED TO KNOW", 1) > 0 Or InStr(1, Com4Sentence, "IS THERE SOMETHING YOU WANT TO KNOW", 1) > 0 Or InStr(1, Com4Sentence, "IS THERE SOMETHING I COULD EXPLAIN", 1) > 0 Or InStr(1, Com4Sentence, "IS THERE SOMETHING I CAN EXPLAIN", 1) > 0 Or InStr(1, Com4Sentence, "DO YOU HAVE ANY QUESTIONS", 1) > 0 Or InStr(1, Com4Sentence, "DO YOU HAVE A QUESTION", 1) > 0 Or InStr(1, Com4Sentence, "IS THERE SOMETHING ELSE YOU NEED TO KNOW", 1) > 0 Or InStr(1, Com4Sentence, "IS THERE SOMETHING ELSE YOU WANT TO KNOW", 1) > 0 Or InStr(1, Com4Sentence, "IS THERE SOMETHING ELSE I COULD EXPLAIN", 1) > 0 Or InStr(1, Com4Sentence, "IS THERE SOMETHING ELSE I CAN EXPLAIN", 1) > 0 Or InStr(1, Com4Sentence, "DO YOU HAVE ANY OTHER QUESTIONS", 1) > 0 Or InStr(1, Com4Sentence, "DO YOU HAVE ANOTHER QUESTION", 1) > 0 Or InStr(1, Com4Sentence, "DO YOU HAVE ANY MORE QUESTIONS", 1) > 0 Or InStr(1, Com4Sentence, "DO YOU HAVE MORE QUESTIONS", 1) > 0 Then
2027 If InStr(1, Com4Sentence, "CONCERNING", 1) > 0 Or InStr(1, Com4Sentence, "ABOUT", 1) > 0 Or InStr(1, Com4Sentence, "PERTAINING", 1) > 0 Or InStr(1, Com4Sentence, "RELATION", 1) > 0 Then
2028 RsBrnNoGo = RsBrnNoGo
2029 Else
2030 RsBrnNoGo = 2
2031 End If
2032End If
2033If (HalBrain.CountInstances(" ", Trim(ResearchSentence)) < 2) Then RsBrnNoGo = 2
2034If RsBrnNoGo < 2 Then
2035 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " WAS *", 1)
2036 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " HAVE *", 1)
2037 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " HAS *", 1)
2038 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " AM *", 1)
2039 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " WHO *", 1)
2040 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " WHAT *", 1)
2041 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " WHEN *", 1)
2042 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " WHERE *", 1)
2043 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " WHY *", 1)
2044 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " HOW *", 1)
2045 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " DID *", 1)
2046 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " CAN *", 1)
2047 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " WHICH *", 1)
2048 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " IS *", 1)
2049 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " WILL *", 1)
2050 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " ARE *", 1)
2051 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " DOES *", 1)
2052 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " DO *", 1)
2053 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " DIDN'T *", 1)
2054 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " CAN'T *", 1)
2055 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " ISN'T *", 1)
2056 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " WON'T *", 1)
2057 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " AREN'T *", 1)
2058 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " DOESN'T *", 1)
2059 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " WHO'S *", 1)
2060 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " WHAT'S *", 1)
2061 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " WHERE'S *", 1)
2062 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " HOW'S *", 1)
2063 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " SHOULD *", 1)
2064 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " COULD *", 1)
2065 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " WOULD *", 1)
2066 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " SHOULDN'T *", 1)
2067 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " COULDN'T *", 1)
2068 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " WOULDN'T *", 1)
2069 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(RsBrnSentence, " DEFINE *", 1)
2070 If LenB(RsBrnLineQuestionNo) = 0 Then RsBrnLineQuestionNo = HalBrain.SearchPattern(RsBrnSentence, "* YOU *", 1)
2071 If LenB(RsBrnLineQuestionNo) = 0 Then RsBrnLineQuestionNo = HalBrain.SearchPattern(RsBrnSentence, "* YOUR *", 1)
2072 If LenB(RsBrnLineQuestionNo) = 0 Then RsBrnLineQuestionNo = HalBrain.SearchPattern(RsBrnSentence, "* MY *", 1)
2073 If LenB(RsBrnLineQuestionNo) = 0 Then RsBrnLineQuestionNo = HalBrain.SearchPattern(RsBrnSentence, "* YOU'LL *", 1)
2074 If LenB(RsBrnLineQuestionNo) = 0 Then RsBrnLineQuestionNo = HalBrain.SearchPattern(RsBrnSentence, "* YOU'RE *", 1)
2075 If LenB(RsBrnLineQuestionNo) = 0 Then RsBrnLineQuestionNo = HalBrain.SearchPattern(RsBrnSentence, "* YOU'VE *", 1)
2076 If LenB(RsBrnLineQuestionNo) = 0 Then RsBrnLineQuestionNo = HalBrain.SearchPattern(RsBrnSentence, "* I'LL *", 1)
2077 If LenB(RsBrnLineQuestionNo) = 0 Then RsBrnLineQuestionNo = HalBrain.SearchPattern(RsBrnSentence, "* I'VE *", 1)
2078 If LenB(RsBrnLineQuestionNo) = 0 Then RsBrnLineQuestionNo = HalBrain.SearchPattern(RsBrnSentence, "* I'M *", 1)
2079 If LenB(RsBrnLineQuestionNo) = 0 Then RsBrnLineQuestionNo = HalBrain.SearchPattern(RsBrnSentence, "* YOURS *", 1)
2080 If LenB(RsBrnLineQuestionNo) = 0 Then RsBrnLineQuestionNo = HalBrain.SearchPattern(RsBrnSentence, "* MINE *", 1)
2081 If LenB(RsBrnLineQuestionNo) = 0 Then RsBrnLineQuestionNo = HalBrain.SearchPattern(RsBrnSentence, "* ME *", 1)
2082 If LenB(RsBrnLineQuestionNo) = 0 Then RsBrnLineQuestionNo = HalBrain.SearchPattern(RsBrnSentence, "* I *", 1)
2083 If LenB(RsBrnLineQuestionNo) = 0 Then RsBrnLineQuestionNo = HalBrain.SearchPattern(RsBrnSentence, "* WE *", 1)
2084
2085 If LenB(RsBrnLineQuestion) = 0 Then RsBrnLineQuestion = HalBrain.SearchPattern(ResearchSentence & " ", "*? ", 1)
2086 If LenB(RsBrnLineQuestionNo) = 0 Then RsBrnLineQuestionNo = HalBrain.SearchPattern(ResearchSentence & " ", "*! ", 1)
2087 If LenB(RsBrnLineQuestionNo) = 0 Then RsBrnLineQuestionNo = HalBrain.SearchPattern(ResearchSentence & " ", "*. ", 1)
2088
2089 If LenB(RsBrnLineQuestionNo) = 0 Then
2090 If InStr(1, UserSentence, " IT ", vbTextCompare) > 0 Then RsBrnLineQuestionNo = "True"
2091 If InStr(1, UserSentence, " HE ", vbTextCompare) > 0 Then RsBrnLineQuestionNo = "True"
2092 If InStr(1, UserSentence, " SHE ", vbTextCompare) > 0 Then RsBrnLineQuestionNo = "True"
2093 If InStr(1, UserSentence, " THEY ", vbTextCompare) > 0 Then RsBrnLineQuestionNo = "True"
2094 If InStr(1, UserSentence, " ITS ", vbTextCompare) > 0 Then RsBrnLineQuestionNo = "True"
2095 If InStr(1, UserSentence, " IT'S ", vbTextCompare) > 0 Then RsBrnLineQuestionNo = "True"
2096 If InStr(1, UserSentence, " HIS ", vbTextCompare) > 0 Then RsBrnLineQuestionNo = "True"
2097 If InStr(1, UserSentence, " HER ", vbTextCompare) > 0 Then RsBrnLineQuestionNo = "True"
2098 If InStr(1, UserSentence, " THEIR ", vbTextCompare) > 0 Then RsBrnLineQuestionNo = "True"
2099 If InStr(1, UserSentence, " HIM ", vbTextCompare) > 0 Then RsBrnLineQuestionNo = "True"
2100 If InStr(1, UserSentence, " THEM ", vbTextCompare) > 0 Then RsBrnLineQuestionNo = "True"
2101 If InStr(1, UserSentence, " WE ", vbTextCompare) > 0 Then RsBrnLineQuestionNo = "True"
2102 If InStr(1, UserSentence, " US ", vbTextCompare) > 0 Then RsBrnLineQuestionNo = "True"
2103 If InStr(1, UserSentence, " OUR ", vbTextCompare) > 0 Then RsBrnLineQuestionNo = "True"
2104 If (HalBrain.CountInstances(" ", Trim(ResearchSentence)) < 10) Then
2105 If InStr(1, UserSentence, " THAT ", vbTextCompare) > 0 Then RsBrnLineQuestionNo = "True"
2106 If InStr(1, UserSentence, " AMONG ", vbTextCompare) > 0 Then RsBrnLineQuestionNo = "True"
2107 End If
2108 End If
2109
2110 If LenB(RsBrnLineQuestion) <> 0 And LenB(RsBrnLineQuestionNo) = 0 Then
2111 RsBrnGetAnswer = True
2112 Else
2113 RsBrnGetAnswer = False
2114 End If
2115 'If HalBrain.CheckTableExistence(RsBrnTableName) = True And Len(Trim(UserSentence)) > 15 Then
2116 If RsBrnGetAnswer = True And HalBrain.CheckTableExistence(RsBrnTableName) = True Then
2117 'If Len(GetResponse) < 4 Then
2118 UserBrainRel = 0
2119 HalUserBrain = HalBrain.QABrain(LongUserSent, RsBrnTableName, UserBrainRel)
2120 If HalBrain.CheckRepetition(HalUserBrain, UserSentence) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevSent) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevUserSent) = True Then UserBrainRel = 0
2121 If UserBrainRel > HighestRel Then
2122 HighestRel = UserBrainRel
2123 HighestRelResponse = HalUserBrain
2124 End If
2125 Score = UserBrainRel + 1
2126 If Score > 30 And Score <= 90 Then Score = Score + 5
2127 If Score > 10 And Score <= 30 Then Score = Score + 3
2128 If Score => 5 And Score <= 10 Then Score = Score + 1
2129 Hurdle = GainControl + 1
2130 RsBrnTrump = HighestRel
2131 HalXBrain.AppendFile RsBrnDir2 & "RsBrnChosen.txt", "HalUserBrain - " & HalUserBrain & " HighestRelResponse - " & HighestRelResponse & " UserBrainRel - " & UserBrainRel & " HighestRel - " & HighestRel & " GainControl - " & GainControl
2132 If ((Score > Hurdle) And (Score > RsBrnTrump)) Or ((Score > 20) And (Score > RsBrnTrump)) Then
2133 Com4RBlock = True
2134 If DudResponseMust <> False Then
2135 GetResponse = HalUserBrain & vbCrLf & DudResponseMust & vbCrLf
2136 Else
2137 GetResponse = HalUserBrain & vbCrLf
2138 End If
2139 HalBrain.ReadOnlyMode = True
2140 End If
2141 'End If
2142 End If
2143End If
2144
2145
2146
2147
2148EmotTimer = Now + 100 / 1440
2149CuriousLastIdleResponse = Now + 100 / 1440
2150LastIdleResponse = Now + 100 / 1440
2151MusicLastIdleResponse = Now + 100 / 1440
2152SysWarIdleResponse = Now + 100 / 1440
2153RsBrnResponse = Now + 100 / 1440
2154
2155
2156Set MarkovHalXBrain1 = CreateObject("UltraHalAsst.Brain")
2157MarkovHalXBrain1.AppendFile MarkovDir & "UserSentence.txt", "USER: " & UserSentence & " ORIGINAL:" & OriginalSentence
2158
2159'Now we set up a premise for the learning section of the plugin that must be true.
2160
2161MarkovNoGo = 0
2162MarkovNoGo2 = ""
2163Com4Sentence = " " & Trim(UserSentence) & " "
2164If InStr(1, GetResponse, "<TOPIC>", vbTextCompare) Or InStr(1, GetResponse, "<YESRES>", vbTextCompare) Or InStr(1, GetResponse, "<EXCLUSIVE>", vbTextCompare) Then MarkovNoGo2 = "True"
2165If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*FACEBOOK*", 2)
2166If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*VIRTUAL HUMANS FORUM*", 2)
2167If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*950*", 2)
2168If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*INTERNET T*", 2)
2169If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*MSN*", 2)
2170If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*FRIENDSTER*", 2)
2171If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*GOOGLE*", 2)
2172If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*ZABAWARE FORUM*", 2)
2173If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*YAHOO MAIL*", 2)
2174If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*YAH*O", 2)
2175If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*NATIONAL NEWS*", 2)
2176If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*LOCAL NEWS*", 2)
2177If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*WEATHER*", 2)
2178If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GOOGLE SEARCH *", 2)
2179If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*WIKIPEDIA SEARCH *", 2)
2180If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*PICTURE SEARCH *", 2)
2181If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*IMAGE SEARCH *", 2)
2182If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*MAP SEARCH *", 2)
2183If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*WEB ADDRESS *", 3)
2184If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*WEBSITE *", 3)
2185If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*NEWS SEARCH *", 2)
2186If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*RADIO STATION SEARCH *", 2)
2187If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*INTERNET RADIO*SEARCH *", 3)
2188If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*VIDEO SEARCH *", 2)
2189If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*BBC RA*", 3)
2190If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*FILIPINO RA*", 3)
2191If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*PHONE NUMBER SEARCH *", 2)
2192If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*STOCK SEARCH *", 2)
2193If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*BOOK SEARCH *", 2)
2194If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*PRODUCT SEARCH *", 2)
2195If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*BUSINESS SEARCH * IN *", 2)
2196If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*BUSINESS SEARCH * IN *", 3)
2197If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*NATIONAL BUSINESS SEARCH *", 2)
2198If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, "*GO TO*PEOPLE SEAR*", 3)
2199If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, " RUN *", 1)
2200If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, " OPEN *", 1)
2201If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, " PLAY A SONG *", 1)
2202If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, " GO TO SLE*P*", 1)
2203If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, " WAKE *P*", 1)
2204If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, " INDEX MP*", 1)
2205If MarkovNoGo2 = "" Then MarkovNoGo2 = HalBrain.SearchPattern(Com4Sentence, " INDEX IMA*", 1)
2206If MarkovNoGo2 <> "" Then MarkovNoGo = 2
2207If InStr(1, Com4Sentence, ComputerName, vbTextCompare) > 0 Then MarkovNoGo = 2
2208If InStr(1, Com4Sentence, "CURRENT", 1) > 0 Then MarkovNoGo = MarkovNoGo + 1
2209If InStr(1, Com4Sentence, "NEWS", 1) > 0 Then MarkovNoGo = MarkovNoGo + 1
2210If InStr(1, Com4Sentence, "LATEST", 1) > 0 Then MarkovNoGo = MarkovNoGo + 1
2211If InStr(1, Com4Sentence, "WEATHER", 1) > 0 Then MarkovNoGo = MarkovNoGo + 1
2212If InStr(1, Com4Sentence, "FORCAST", 1) > 0 Then MarkovNoGo = MarkovNoGo + 1
2213If InStr(1, Com4Sentence, "FORECAST", 1) > 0 Then MarkovNoGo = MarkovNoGo + 1
2214If InStr(1, Com4Sentence, "PLEASE RECORD", 1) > 0 Or InStr(1, Com4Sentence, "PLEASE RESEARCH", 1) > 0 Or InStr(1, Com4Sentence, "GO TO CURRENT LOG", 1) > 0 Or InStr(1, Com4Sentence, "GO TO LOG", 1) > 0 Or InStr(1, Com4Sentence, "PLEASE READ", 1) > 0 Or InStr(1, Com4Sentence, "PLEASE SING", 1) > 0 Or InStr(1, Com4Sentence, "I'LL BE BACK", 1) > 0 Or InStr(1, Com4Sentence, "BE QUIET", 1) > 0 Or InStr(1, Com4Sentence, "SHUT UP", 1) Or InStr(1, Com4Sentence, "I AM BUSY", 1) > 0 Or InStr(1, Com4Sentence, "I'M BUSY", 1) > 0 Or InStr(1, Com4Sentence, "PLEASE REPEAT", 1) > 0 Or InStr(1, Com4Sentence, "LOG ENTRY", 1) > 0 Then MarkovNoGo = 2
2215If InStr(1, Com4Sentence, "IS THERE SOMETHING YOU NEED TO KNOW", 1) > 0 Or InStr(1, Com4Sentence, "IS THERE SOMETHING YOU WANT TO KNOW", 1) > 0 Or InStr(1, Com4Sentence, "IS THERE SOMETHING I COULD EXPLAIN", 1) > 0 Or InStr(1, Com4Sentence, "IS THERE SOMETHING I CAN EXPLAIN", 1) > 0 Or InStr(1, Com4Sentence, "DO YOU HAVE ANY QUESTIONS", 1) > 0 Or InStr(1, Com4Sentence, "DO YOU HAVE A QUESTION", 1) > 0 Or InStr(1, Com4Sentence, "IS THERE SOMETHING ELSE YOU NEED TO KNOW", 1) > 0 Or InStr(1, Com4Sentence, "IS THERE SOMETHING ELSE YOU WANT TO KNOW", 1) > 0 Or InStr(1, Com4Sentence, "IS THERE SOMETHING ELSE I COULD EXPLAIN", 1) > 0 Or InStr(1, Com4Sentence, "IS THERE SOMETHING ELSE I CAN EXPLAIN", 1) > 0 Or InStr(1, Com4Sentence, "DO YOU HAVE ANY OTHER QUESTIONS", 1) > 0 Or InStr(1, Com4Sentence, "DO YOU HAVE ANOTHER QUESTION", 1) > 0 Or InStr(1, Com4Sentence, "DO YOU HAVE ANY MORE QUESTIONS", 1) > 0 Or InStr(1, Com4Sentence, "DO YOU HAVE MORE QUESTIONS", 1) > 0 Then
2216 If InStr(1, Com4Sentence, "CONCERNING", 1) > 0 Or InStr(1, Com4Sentence, "ABOUT", 1) > 0 Or InStr(1, Com4Sentence, "PERTAINING", 1) > 0 Or InStr(1, Com4Sentence, "RELATION", 1) > 0 Then
2217 MarkovNoGo = MarkovNoGo
2218 Else
2219 MarkovNoGo = 2
2220 End If
2221End If
2222If MarkovNoGo < 2 Then
2223 If InStr(UserSentence, " YOU ") = 0 And InStr(UserSentence, " YOU'LL ") = 0 And InStr(UserSentence, " YOU'VE ") = 0 And InStr(UserSentence, " YOU ") = 0 And InStr(UserSentence, " YOUR ") = 0 And InStr(UserSentence, " YOURS ") = 0 And InStr(UserSentence, " YOU'RE ") = 0 And InStr(UserSentence, " YOURSELF ") = 0 And InStr(OriginalSentence, """") = 0 Then
2224 If HalBrain.TopicSearch(UserSentence, "ephemeralDetect") <> "True" And HalBrain.ReadOnlyMode <> True Then
2225
2226 'We start by adding the UserSentence to the MarkovReasoningl4 table.
2227 'We need to change the input sentences to fit the profile of the database that we will create later.
2228
2229 MarkovAnswer = ""
2230 MarkovSentence = Trim(UserSentence)
2231 MarkovSentence = Replace(MarkovSentence,"&","<MARKOVAMPER>",1,-1,vbTextCompare)
2232 MarkovSentence = Replace(MarkovSentence,",","<MARKOVCOMMA>",1,-1,vbTextCompare)
2233 MarkovSentence = Replace(MarkovSentence,":","<MARKOVCOLON>",1,-1,vbTextCompare)
2234 MarkovSentence = Replace(MarkovSentence,";","<MARKOVSEMI>",1,-1,vbTextCompare)
2235 MarkovSentence = Replace(MarkovSentence," ' "," ",1,-1,vbTextCompare)
2236 MarkovSentence = Replace(MarkovSentence," "" "," ",1,-1,vbTextCompare)
2237 MarkovSentence = Replace(MarkovSentence,"-","<MARKOVDASH>",1,-1,vbTextCompare)
2238 MarkovSentence = Replace(MarkovSentence," "," ",1,-1,vbTextCompare)
2239 MarkovGetrespPunc4 = ""
2240 MarkovGetrespPunc2 = ""
2241 MarkovGetrespPunc3 = ""
2242 MarkovGetrespPunc5 = ""
2243 If LenB(MarkovGetrespPunc2) = 0 Then MarkovGetrespPunc2 = HalBrain.SearchPattern(OriginalSentence, "*?", 1)
2244 If LenB(MarkovGetrespPunc3) = 0 Then MarkovGetrespPunc3 = HalBrain.SearchPattern(OriginalSentence, "*!", 1)
2245 If LenB(MarkovGetrespPunc4) = 0 Then MarkovGetrespPunc4 = HalBrain.SearchPattern(OriginalSentence, "*.", 1)
2246 If LenB(MarkovGetrespPunc5) = 0 Then MarkovGetrespPunc5 = HalBrain.SearchPattern(" " & Trim(MarkovSentence) & " ", " I WONDER *", 1)
2247 If LenB(MarkovGetrespPunc5) = 0 Then
2248 If LenB(MarkovGetrespPunc2) <> 0 Then MarkovSentence = MarkovSentence & " " & "<MARKOVQUESTION>"
2249 If LenB(MarkovGetrespPunc3) <> 0 Then MarkovSentence = MarkovSentence & " " & "<MARKOVEXCITE>"
2250 If LenB(MarkovGetrespPunc4) <> 0 Then MarkovSentence = MarkovSentence & " " & "<MARKOVSTATEMENT>"
2251 Else
2252 MarkovSentence = MarkovSentence & " " & "<MARKOVSTATEMENT>"
2253 End If
2254
2255
2256 MarkovSentence = " <MARKOVEND>" & Trim(MarkovSentence) & " <MARKOVEND> "
2257
2258 'That will change a UserSentence like: " I KNOW , BUT I LIKE IT " into " <MARKOVEND>I KNOW <MARKOVCOMMA> BUT I LIKE IT <MARKOVEND> "
2259
2260 If (HalBrain.CountInstances(" ", MarkovSentence) > 7) And (HalBrain.CountInstances(" ", MarkovSentence) < 30) Then
2261
2262 'The algorithm needs to know the beginning and end of the sentence, in order to know where to start and stop the database creation.
2263
2264 MarkovFirstWord = HalBrain.SearchPattern(MarkovSentence, " <MARKOVEND>* *", 1)
2265 MarkovFirstWord = "<MARKOVEND>" & MarkovFirstWord
2266
2267 'Now we start building the pattern
2268
2269 MarkovFirstString = " " & MarkovFirstWord & " "
2270 MarkovFirstString = MarkovFirstString & HalBrain.SearchPattern(MarkovSentence, " <MARKOVEND>* * * * *", 2)
2271 MarkovFirstString = MarkovFirstString & " "
2272 MarkovFirstString = MarkovFirstString & HalBrain.SearchPattern(MarkovSentence, " <MARKOVEND>* * * * *", 3)
2273 MarkovFirstString = MarkovFirstString & " "
2274 MarkovFirstString = MarkovFirstString & HalBrain.SearchPattern(MarkovSentence, " <MARKOVEND>* * * * *", 4)
2275 MarkovFirstString = MarkovFirstString & " "
2276 MarkovCurrentString = MarkovFirstString
2277 MarkovTableName = "MarkovReasoningl4"
2278 If LenB(HalBrain.TopicSearch(MarkovCurrentString, "MarkovReasoningl4")) = 0 Then
2279 HalBrain.AddToTable "MarkovStartersl4", "Sentence", MarkovFirstString, ""
2280 End If
2281
2282 'LOOK IN DATABASE FOR MARKOVCURRENTSTRING AND THE RELATED TOPIC AND SAVE THE SEARCH AND TOPIC STRINGS
2283
2284 Dim MarkovTemp()
2285 For i = 1 To 35
2286
2287 MarkovNextWord = ""
2288 MarkovNextWord = HalBrain.SearchPattern(MarkovSentence, "*" & Trim(MarkovCurrentString) & " * * ", 2)
2289 If LenB(MarkovNextWord) = 0 Then
2290 MarkovNextWord = HalBrain.SearchPattern(MarkovSentence, "*" & Trim(MarkovCurrentString) & " * <MARKOVEND> ", 2)
2291 MarkovNextWord = "<MARKOVEND>"
2292 End If
2293 If LenB(HalBrain.TopicSearch(MarkovCurrentString, "MarkovReasoningl4")) = 0 Then
2294 HalBrain.AddToTable "MarkovReasoningl4", "TopicSearch", MarkovCurrentString, " " & MarkovNextWord & ", "
2295 Else
2296 MarkovTempData = ""
2297 MarkovTempData = HalBrain.TopicSearch(MarkovCurrentString, "MarkovReasoningl4")
2298 MarkovTempDataPlus = MarkovTempData & MarkovNextWord & ", "
2299 HalBrain.RunQuery "UPDATE " & MarkovTableName & " SET topic = " & """" & MarkovTempDataPlus & """" & " WHERE searchString = " & """" & MarkovCurrentString & """", MarkovTemp
2300 End If
2301 If MarkovNextWord = "<MARKOVEND>" Then
2302 Exit For
2303 Else
2304 MarkovBeforeRemove = MarkovCurrentString & MarkovNextWord & " "
2305 MarkovRemoveWord1 = HalBrain.SearchPattern(MarkovBeforeRemove, " * * * * * ", 2)
2306 MarkovRemoveWord2 = HalBrain.SearchPattern(MarkovBeforeRemove, " * * * * * ", 3)
2307 MarkovRemoveWord3 = HalBrain.SearchPattern(MarkovBeforeRemove, " * * * * * ", 4)
2308 MarkovRemoveWord4 = HalBrain.SearchPattern(MarkovBeforeRemove, " * * * * * ", 5)
2309 MarkovCurrentString = " " & MarkovRemoveWord1 & " " & MarkovRemoveWord2 & " " & MarkovRemoveWord3 & " " & MarkovRemoveWord4 & " "
2310 End If
2311 Next
2312 End If
2313 End If
2314 End If
2315 If (HalBrain.CountInstances(" ", Trim(OriginalSentence)) > 1) Then
2316
2317 'We start a loop to get a response that might contain the CurrentSubject or a non repeating response.
2318 Set MarkovobjFSO1 = CreateObject("Scripting.FileSystemObject")
2319 If MarkovobjFSO1.FileExists(MyMarkovDir & "MarkovReturn.txt") Then
2320 MarkovobjFSO1.DeleteFile(MyMarkovDir & "MarkovReturn.txt")
2321 End If
2322 MarkovTableName = "MarkovTemp"
2323 If HalBrain.CheckTableExistence(MarkovTableName) = True Then
2324 'HalBrain.RunQuery "DELETE FROM " & MarkovTableName & " LIMIT 2", MarkovTempQuery
2325 'HalBrain.RunQuery "DELETE FROM " & MarkovTableName, MarkovTempQuery
2326
2327 Else
2328 If HalBrain.ReadOnlyMode = True Then
2329 MarkovWrite = False
2330 Else
2331 MarkovWrite = True
2332 End If
2333 HalBrain.ReadOnlyMode = False
2334 HalBrain.CreateTable MarkovTableName, "Brain", ""
2335 If MarkovWrite = False Then HalBrain.ReadOnlyMode = True
2336 End If
2337
2338 For l = 1 To 10
2339
2340 'Now we get a possible answer from the MarkovReasoningl4 table.
2341 'LOOK FOR THE USERSENTENCE FIRST 4 WORDS AND START THE CHAIN
2342
2343 MarkovAnswerCurrent = HalBrain.ChooseSentenceFromFile("MarkovStartersl4")
2344 MarkovAnswerLess = MarkovAnswerCurrent
2345 If LenB(MarkovAnswerCurrent) = 0 Then Exit For
2346
2347 'USE THAT STRING TO START A CHAIN UNTIL <MARKOVEND> IS REACHED
2348
2349 For k = 1 To 45
2350
2351 MarkovPossibilities = HalBrain.TopicSearch(MarkovAnswerLess, "MarkovReasoningl4")
2352 MarkovPossibilities = Trim(MarkovPossibilities)
2353 If LenB(HalBrain.SearchPattern(MarkovPossibilities, "* *", 2)) <> 0 Then
2354 MarkovPossibilities = MarkovPossibilities & "<CUTTER>"
2355 MarkovPossibilities = Replace(MarkovPossibilities,",<CUTTER>","",1,-1,vbTextCompare)
2356 Else
2357 MarkovPossibilities = Replace(MarkovPossibilities,",","",1,-1,vbTextCompare)
2358 End If
2359 MarkovAnswerChoice = WN.ChooseRandomWord(MarkovPossibilities)
2360 MarkovAnswerCurrent = MarkovAnswerCurrent & MarkovAnswerChoice & " "
2361 MarkovAnswerLess = Replace(MarkovAnswerLess," "," ",1,-1,vbTextCompare)
2362 If LenB(HalBrain.SearchPattern(MarkovAnswerCurrent, "* * <MARKOVEND> ", 2)) <> 0 Then
2363 Exit For
2364 Else
2365 MarkovAnswerBefore = MarkovAnswerLess & MarkovAnswerChoice & " "
2366 MarkovRemoveAnswer1 = HalBrain.SearchPattern(MarkovAnswerBefore, " * * * * * ", 2)
2367 MarkovRemoveAnswer2 = HalBrain.SearchPattern(MarkovAnswerBefore, " * * * * * ", 3)
2368 MarkovRemoveAnswer3 = HalBrain.SearchPattern(MarkovAnswerBefore, " * * * * * ", 4)
2369 MarkovRemoveAnswer4 = HalBrain.SearchPattern(MarkovAnswerBefore, " * * * * * ", 5)
2370 MarkovAnswerLess = " " & MarkovRemoveAnswer1 & " " & MarkovRemoveAnswer2 & " " & MarkovRemoveAnswer3 & " " & MarkovRemoveAnswer4 & " "
2371 End If
2372 Next
2373
2374
2375 'Now we form the database answer into a usable sentence for a response
2376
2377 If LenB(HalBrain.SearchPattern(MarkovAnswerCurrent, " <MARKOVEND>* * * <MARKOVEND> ", 3)) = 0 Then MarkovAnswerCurrent = ""
2378 MarkovAnswerCurrent = Replace(MarkovAnswerCurrent," "," ",1,-1,vbTextCompare)
2379 MarkovAnswerCurrent = Trim(MarkovAnswerCurrent)
2380 MarkovAnswerCurrent = Replace(MarkovAnswerCurrent," <MARKOVCOMMA> ",", ",1,-1,vbTextCompare)
2381 MarkovAnswerCurrent = Replace(MarkovAnswerCurrent,"<MARKOVEND>","",1,-1,vbTextCompare)
2382 MarkovAnswerCurrent = Replace(MarkovAnswerCurrent," <MARKOVCOLON> ",": ",1,-1,vbTextCompare)
2383 MarkovAnswerCurrent = Replace(MarkovAnswerCurrent," <MARKOVSEMI> ","; ",1,-1,vbTextCompare)
2384 MarkovAnswerCurrent = Replace(MarkovAnswerCurrent," <MARKOVDASH> ","-",1,-1,vbTextCompare)
2385 MarkovAnswerCurrent = Replace(MarkovAnswerCurrent," <MARKOVQUESTION>","?",1,-1,vbTextCompare)
2386 MarkovAnswerCurrent = Replace(MarkovAnswerCurrent," <MARKOVEXCITE>","!",1,-1,vbTextCompare)
2387 MarkovAnswerCurrent = Replace(MarkovAnswerCurrent," <MARKOVSTATEMENT>",".",1,-1,vbTextCompare)
2388 MarkovAnswerCurrent = Replace(MarkovAnswerCurrent,"<MARKOVAMPER>","&",1,-1,vbTextCompare)
2389 MarkovAnswerCurrent = Replace(MarkovAnswerCurrent," "," ",1,-1,vbTextCompare)
2390 MarkovAnswerCurrent = Trim(MarkovAnswerCurrent)
2391 MarkovAnswer = MarkovAnswerCurrent
2392
2393 MarkovGetrespPunc4 = ""
2394 MarkovGetrespPunc2 = ""
2395 MarkovGetrespPunc3 = ""
2396 If LenB(MarkovGetrespPunc2) = 0 Then MarkovGetrespPunc2 = HalBrain.SearchPattern(MarkovAnswer, "*?", 1)
2397 If LenB(MarkovGetrespPunc3) = 0 Then MarkovGetrespPunc3 = HalBrain.SearchPattern(MarkovAnswer, "*!", 1)
2398 If LenB(MarkovGetrespPunc4) = 0 Then MarkovGetrespPunc4 = HalBrain.SearchPattern(MarkovAnswer, "*.", 1)
2399 If LenB(MarkovGetrespPunc2) <> 0 Or LenB(MarkovGetrespPunc3) <> 0 Or LenB(MarkovGetrespPunc4) <> 0 Then
2400 MarkovAnswer = MarkovAnswer
2401 Else
2402 MarkovLineQuestion = ""
2403 MarkovLineQuestionNo = ""
2404
2405 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " WAS *", 1)
2406 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " HAVE *", 1)
2407 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " HAS *", 1)
2408 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " AM *", 1)
2409 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " WHO *", 1)
2410 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " WHAT *", 1)
2411 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " WHEN *", 1)
2412 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " WHERE *", 1)
2413 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " WHY *", 1)
2414 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " HOW *", 1)
2415 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " DID *", 1)
2416 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " CAN *", 1)
2417 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " WHICH *", 1)
2418 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " IS *", 1)
2419 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " WILL *", 1)
2420 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " ARE *", 1)
2421 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " DOES *", 1)
2422 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " DO *", 1)
2423 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " DIDN'T *", 1)
2424 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " CAN'T *", 1)
2425 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " ISN'T *", 1)
2426 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " WON'T *", 1)
2427 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " AREN'T *", 1)
2428 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " DOESN'T *", 1)
2429 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " WHO'S *", 1)
2430 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " WHAT'S *", 1)
2431 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " WHERE'S *", 1)
2432 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " HOW'S *", 1)
2433 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " SHOULD *", 1)
2434 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " COULD *", 1)
2435 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " WOULD *", 1)
2436 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " SHOULDN'T *", 1)
2437 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " COULDN'T *", 1)
2438 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.SearchPattern(" " & Trim(MarkovAnswer) & " ", " WOULDN'T *", 1)
2439 If LenB(MarkovLineQuestion) = 0 Then MarkovLineQuestion = HalBrain.PatternDB(Trim(MarkovAnswer), "sharedQuestions")
2440
2441 If (InStr(1, MarkovAnswer, "!", 1) = 0) And (LenB(MarkovLineQuestion) <> 0) And (InStr(1, MarkovAnswer, ",", 1) = 0) Then
2442 MarkovAnswer = MarkovAnswer & "?"
2443 End If
2444 If (InStr(1, MarkovAnswer, "?", 1) = 0 And InStr(1, MarkovAnswer, "!", 1) = 0 And LenB(MarkovLineQuestion) = 0) Or MarkovLineQuestionNo <> "" Then
2445 MarkovAnswer = MarkovAnswer & "."
2446 End If
2447 End If
2448 MarkovAnswer = HalBrain.FixCase(MarkovAnswer)
2449 MarkovAnswer = HalBrain.HalFormat(MarkovAnswer)
2450 MyMarkovDir = MarkovDir()
2451 'HalXBrain.AppendFile MyMarkovDir & "MarkovReturn.txt", MarkovAnswer & vbTab & MarkovAnswer
2452 MarkovLearn = ""
2453 If HalBrain.ReadOnlyMode = True Then
2454 HalBrain.ReadOnlyMode = False
2455 MarkovLearn = True
2456 Else
2457 MarkovLearn = False
2458 End If
2459 HalBrain.AddToTable MarkovTableName, "Brain", UCase(Trim(HalBrain.AlphaNumericalOnly(MarkovAnswer))), MarkovAnswer
2460 HalBrain.LimitSize "MarkovTemp", 50000
2461 If MarkovLearn = True Then HalBrain.ReadOnlyMode = True
2462 Next
2463
2464 'If no response is found yet, try creating a response from the Markov sentence table for GetResponse.
2465
2466 'If (Len(GetResponse) < 4 And Len(UserSentence) > 15) Then
2467 UserBrainRel = 0
2468 HalUserBrain = HalBrain.QABrain(LongUserSent, MarkovTableName, UserBrainRel)
2469 If HalBrain.CheckRepetition(HalUserBrain, UserSentence) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevSent) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevUserSent) = True Then UserBrainRel = 0
2470 If UserBrainRel > HighestRel Then
2471 HighestRel = UserBrainRel
2472 HighestRelResponse = HalUserBrain
2473 End If
2474 Score = UserBrainRel + 1
2475 Hurdle = GainControl + 1
2476 MarkovTrump = HighestRel
2477 Set MarkovHalXBrain2 = CreateObject("UltraHalAsst.Brain")
2478 MarkovHalXBrain2.AppendFile MyMarkovDir & "MarkovChosen.txt", "HalUserBrain - " & HalUserBrain & " HighestRelResponse - " & HighestRelResponse & " UserBrainRel - " & UserBrainRel & " HighestRel - " & HighestRel & " GainControl - " & GainControl
2479 If (Score > Hurdle) And (Score > MarkovTrump) Then
2480 If DudResponseMust <> False Then
2481 GetResponse = HalUserBrain & vbCrLf & DudResponseMust & vbCrLf
2482 Else
2483 GetResponse = HalUserBrain & vbCrLf
2484 End If
2485 'HalBrain.ReadOnlyMode = False
2486 End If
2487 'End If
2488 End If
2489End If
2490
2491
2492
2493
2494 'SAVE: USER'S SEX
2495 'If the user just told Hal their sex and Hal didn't know before, then
2496 'Hal will save it in a table for future reference
2497 If HalBrain.ReadOnlyMode = False And NewSex <> "" Then
2498 If HalBrain.CheckTableExistence(Trim(LCase(UserName)) & "_Sex") = False Then
2499 'Create table for this person if it doesn't exist
2500 HalBrain.CreateTable Trim(LCase(UserName)) & "_Sex", "TopicSearch", "autoLearningBrain"
2501 End If
2502 'Store user response in this table
2503 HalBrain.AddToTable Trim(LCase(UserName)) & "_Sex", "TopicSearch", Trim(TempName), Trim(UCase(NewSex))
2504 End If
2505
2506 'RESPOND: GREETINGS
2507 'This takes care of the user greeting Hal
2508 'First Hal checks to see if the user is greeting right now.
2509 If HalBrain.TopicSearch(UserSentence, "helloDetect") = "True" Then SaidHello = True Else SaidHello = False
2510 If HalBrain.TopicSearch(UserSentence, "helloDisqualify") = "True" Then SaidHello = False
2511 'Second, Hal checks to see if the user said a greeting on the last exchange.
2512 If HalBrain.TopicSearch(PrevUserSent, "helloDetect") = "True" Then PrevHello = True Else PrevHello = False
2513 If HalBrain.TopicSearch(UserSentence, "helloDisqualify") = "True" Then PrevHello = False
2514 'This will get a greeting from a file. It will pass the current hour and either
2515 'the letter A or B to a topic search file and it will get back a greeting based
2516 'on the current time. Each hour has 2 possible greetings, the A greeting and B
2517 'greeting, which is randomly chosen.
2518 If SaidHello = True And PrevHello = False Then
2519 If Rnd * 100 < 50 Then LetterChoice = "A" Else LetterChoice = "B"
2520 HalGreeting = HalBrain.TopicSearch(" " & Trim(Hour(Now)) & LetterChoice & " ", "hello1")
2521 End If
2522 'This will get a greeting from a file that is not based on the current time
2523 'if the user said Hello again
2524 If SaidHello = True And PrevHello = True Then HalGreeting = HalBrain.ChooseSentenceFromFile("hello2")
2525
2526 'RESPOND: GOODBYES
2527 'Check if the user is saying bye right now
2528 If HalBrain.TopicSearch(UserSentence, "byeDetect") = "True" Then SaidBye = True
2529 If InStr(1, UserSentence, " see me ", 1) > 0 And Len(UserSentence) < 10 Then SaidBye = True
2530 If HalBrain.TopicSearch(UserSentence, "byeDisqualify") = "True" Then SaidBye = False
2531 'Check if Hal said bye in the previous sentence
2532 If HalBrain.TopicSearch(PrevUserSent, "byeDetect") = "True" Then PrevBye = True
2533 If InStr(1, PrevUserSent, " see me ", 1) > 0 And Len(UserSentence) < 10 Then PrevBye = True
2534 If HalBrain.TopicSearch(PrevUserSent, "byeDisqualify") = "True" Then PrevBye = False
2535 If SaidBye = True And PrevBye = False Then HalGreeting = HalBrain.ChooseSentenceFromFile("bye1")
2536 If SaidBye = True And PrevBye = True Then HalGreeting = HalBrain.ChooseSentenceFromFile("bye2")
2537
2538 'RESPOND: POLITE INQUIRIES
2539 'Hal checks to see if the user is making a polite inquiry into Hal's well being
2540 'e.g. "How are you doing?"
2541 If InStr(1, UserSentence, "How am I ", 1) > 0 And Len(UserSentence) < 14 Then PoliteAsk = True
2542 If InStr(1, UserSentence, "How are you ", 1) > 0 And Len(UserSentence) < 16 Then PoliteAsk = True
2543 If InStr(1, UserSentence, "What's new", 1) > 0 And Len(UserSentence) < 17 Then PoliteAsk = True
2544 If InStr(1, UserSentence, "What is new", 1) > 0 And Len(UserSentence) < 18 Then PoliteAsk = True
2545 If InStr(1, UserSentence, "Whats new", 1) > 0 And Len(UserSentence) < 16 Then PoliteAsk = True
2546 If HalBrain.TopicSearch(UserSentence, "PoliteAskDetect") = "True" Then PoliteAsk = True
2547 If PoliteAsk = True Then HalGreeting = HalBrain.ChooseSentenceFromFile("politeAsk1") & HalBrain.ChooseSentenceFromFile("politeAsk2")
2548
2549 'RESPOND: GREETINGS, GOODBYES, AND POLITE INQUIRIES
2550 'If one of the 3 functions above generated a response, we will add it
2551 'to Hal's response. The variable HalGreeting is saved for later use
2552 'as well in case other functions wish to know if Hal hal just greeted
2553 'the user.
2554 If HalGreeting <> "" Then GetResponse = GetResponse & HalGreeting & vbCrLf & "<NOMORE>"
2555 HalBrain.DebugWatch GetResponse, "Greetings"
2556
2557 Rem PLUGIN: PLUGINAREA5
2558 'read a story
2559Set objFSO = CreateObject("Scripting.FileSystemObject")
2560DudProceed = False
2561MyClipDir = DudClipDir()
2562ClipRead = OriginalSentence
2563If InStr(1, ClipRead, "PLEASE READ STORY LIST", 1) > 0 Or InStr(1, ClipRead, "PLEASE READ THE STORY LIST", 1) > 0 Then StoryRead = "story list"
2564If InStr(1, ClipRead, "PLEASE READ POEM LIST", 1) > 0 Or InStr(1, ClipRead, "PLEASE READ THE POEM LIST", 1) > 0 Then StoryRead = "poem list"
2565If InStr(1, ClipRead, "PLEASE READ WEB COMMANDS", 1) > 0 Or InStr(1, ClipRead, "PLEASE READ THE WEB COMMANDS", 1) > 0 Then StoryRead = "WEB COMMANDS"
2566If InStr(1, ClipRead, "PLEASE READ NEWS FEED COMMANDS", 1) > 0 Or InStr(1, ClipRead, "PLEASE READ THE NEWS FEED COMMANDS", 1) > 0 Then StoryRead = "NEWS FEED COMMANDS"
2567If InStr(1, ClipRead, "PLEASE READ WEATHER FEED COMMANDS", 1) > 0 Or InStr(1, ClipRead, "PLEASE READ THE WEATHER FEED COMMANDS", 1) > 0 Then StoryRead = "WEATHER FEED COMMANDS"
2568If InStr(1, ClipRead, "PLEASE READ SONG LIST", 1) > 0 Or InStr(1, ClipRead, "PLEASE READ THE SONG LIST", 1) > 0 Then StoryRead = "SONG LIST"
2569
2570
2571
2572If StoryRead = "" Then StoryRead = HalBrain.SearchPattern(HalBrain.AlphaNumericalOnly(OriginalSentence), "PLEASE READ STORY *", 1)
2573If StoryRead = "" Then StoryRead = HalBrain.SearchPattern(HalBrain.AlphaNumericalOnly(OriginalSentence), "PLEASE READ POEM *", 1)
2574If StoryRead = "" Then StoryRead = HalBrain.SearchPattern(HalBrain.AlphaNumericalOnly(OriginalSentence), "PLEASE READ THE STORY *", 1)
2575If StoryRead = "" Then StoryRead = HalBrain.SearchPattern(HalBrain.AlphaNumericalOnly(OriginalSentence), "PLEASE READ THE POEM *", 1)
2576If StoryRead <> "" And objFSO.FileExists(MyClipDir & StoryRead & ".txt") = True Then
2577 GetResponse = StoryRead & "." & vbCrLf
2578 If GetResponse = StoryRead & "." & vbCrLf Then
2579 DudProceed = True
2580 HalBrain.ReadOnlyMode = True
2581 End If
2582End If
2583 If DudProceed = True Then
2584 If objFSO.FileExists(MyClipDir & StoryRead & ".txt") Then
2585 Set objWSHShell = CreateObject("WScript.Shell")
2586 objWSHShell.Run("""C:\Program Files\Balabolka\balabolka.exe"" -rmq """ & MyClipDir & StoryRead & ".txt""")
2587 End If
2588 HalBrain.ReadOnlyMode = True
2589
2590End If
2591
2592If StoryRead <> "" And objFSO.FileExists(MyClipDir & StoryRead & ".txt") = False Then
2593 GetResponse = " That file does not exist. "
2594HalBrain.ReadOnlyMode = True
2595End If
2596
2597ClipRead = OriginalSentence
2598If InStr(1, ClipRead, "PLEASE READ CLIPBOARD", 1) > 0 Or InStr(1, ClipRead, "PLEASE READ CLIP BOARD", 1) > 0 Or InStr(1, ClipRead, "PLEASE READ THE CLIPBOARD", 1) > 0 Or InStr(1, ClipRead, "PLEASE READ THE CLIP BOARD", 1) > 0 Then
2599
2600Select Case HalBrain.RandomNum(6)
2601Case 1
2602IdleResponse67 = "I would love to."
2603Case 2
2604IdleResponse67 = "Sure."
2605Case 3
2606IdleResponse67 = "Alright."
2607Case 4
2608IdleResponse67 = "Okay."
2609Case 5
2610IdleResponse67 = "Here it is."
2611Case 6
2612IdleResponse67 = "No problem."
2613End Select
2614GetResponse = IdleResponse67
2615
2616 HalBrain.ReadOnlyMode = True
2617
2618
2619
2620
2621MyClipDir = DudClipDir()
2622Set FileSys = CreateObject("Scripting.FileSystemObject")
2623Set FS = CreateObject("Scripting.FileSystemObject")
2624Set HalXBrain = CreateObject("UltraHalAsst.Brain")
2625Set fso = CreateObject("Scripting.FileSystemObject")
2626Set objFSO = CreateObject("Scripting.FileSystemObject")
2627
2628
2629
2630Set objHTML = CreateObject("htmlfile")
2631ClipText = objHTML.ParentWindow.ClipboardData.GetData("text")
2632 ClipText = Replace(ClipText, vbCrLf, Chr(8) & " ", 1, -1, vbTextCompare)
2633
2634 ClipText = Replace(ClipText, "", "", 1, -1, vbTextCompare)
2635
2636 ClipText = Replace(ClipText, " ", " ", 1, -1, vbTextCompare)
2637
2638
2639
2640
2641
2642 If objFSO.FolderExists(MyClipDir) Then ClipFolderDoesExist = True Else ClipFolderDoesExist = False
2643 If ClipFolderDoesExist = False Then
2644 Set objFolder = objFSO.CreateFolder(MyClipDir)
2645 End If
2646
2647If objFSO.FileExists(MyClipDir & "tempclipboard.txt") Then
2648objFSO.DeleteFile(MyClipDir & "tempclipboard.txt")
2649End If
2650
2651
2652HalXBrain.AppendFile MyClipDir & "tempclipboard.txt", ClipText
2653
2654 If objFSO.FileExists(MyClipDir & "tempclipboard.txt") Then
2655 Set objWSHShell = CreateObject("WScript.Shell")
2656 objWSHShell.Run("""C:\Program Files\Balabolka\balabolka.exe"" -rmq """ & MyClipDir & "tempclipboard.txt""")
2657 End If
2658End If
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668If OriginalSentence <> "" Then
2669
2670
2671
2672
2673
2674'The comment above tells Ultra Hal Assistant to insert the following code
2675'on-the-fly into the main brain code in the section referenced.
2676
2677'------------------
2678' Check if the user asked for reorganizing the MP3 table
2679'------------------
2680vrMp3 = False
2681If InStr(UserSentence, " INDEX ") <> 0 And InStr(UserSentence, " MP3 ") <> 0 Then vrMP3 = True
2682
2683If vrMP3 = True Then
2684'------------------
2685' If the MP3 table does not exist, I create it
2686'------------------
2687 HalBrain.ReadOnlyMode = False
2688 vrTableName = "vrMp3"
2689 If HalBrain.CheckTableExistence(vrTableName) = False Then
2690 ' Create table if it doesn't exist
2691 ' It must be of type Brain, to allow partial text search
2692 HalBrain.CreateTable vrTableName, "Brain", "miscData"
2693 Else
2694 ' The 260 parameter is 256 + 4 = Yes/No with Default = No
2695 vrAnswer = MsgBox("Shall I delete the existing index and recreate it from scratch?", 260, "MP3 Reindexing")
2696 If vrAnswer = 6 Then
2697 HalBrain.RunQuery "DELETE FROM " & vrTableName, vrTempQuery
2698 End If
2699 End If
2700'------------------
2701' Ask which is the main MP3 folder
2702'------------------
2703vrMp3Folder = InputBox("Which main folder to you want to reindex?", "MP3 Reindexing", "D:\MP3")
2704'------------------
2705' Read the main MP3 folder
2706'------------------
2707 Set vrFso = CreateObject("Scripting.FileSystemObject")
2708 If vrFso.FolderExists(vrMp3Folder) Then
2709 GetResponse = "I have indexed all the MP3 files in the specified folder and subfolders. "
2710 HalBrain.ReadOnlyMode = False
2711 vrCurrentFolder = vrMp3Folder
2712 Call ReadFolder(vrCurrentFolder, vrMp3Folder)
2713 Else
2714 GetResponse = "The folder " & vrMp3Folder & " does not exist on your computer. "
2715 End If
2716 HalBrain.ReadOnlyMode = True
2717End If
2718
2719'------------------
2720' Check if the user asked for playing a song
2721'------------------
2722vrMp3 = False
2723vrToPlay = ""
2724vrNameToPlay = ""
2725vrToPlay = UCase(HalBrain.SearchPattern(UserSentence, "PLAY * SONG *", 2))
2726If vrToPlay <> "" Then
2727 vrToPlay = " " & vrToPlay & " "
2728 vrToPlay = Replace(vrToPlay," ","xx",1,-1,vbTextCompare)
2729 If HalBrain.CheckTableExistence("vrMp3") = False Then
2730 GetResponse = "I don't find any MP3 index in my brain. "
2731 Else
2732 vrNameToPlay = HalBrain.QABrain(vrToPlay, "vrMp3", 0)
2733 If vrNameToPlay <> "" Then
2734 GetResponse = "Listen to this song; I think it's the one you were talking about. "
2735 'HalCommands = HalCommands & "<RUNPROG>" & vrNameToPlay & "</RUNPROG>"
2736 Set objFSO = CreateObject("Scripting.FileSystemObject")
2737 If objFSO.FileExists(vrNameToPlay) Then
2738 Set objWSHShell = CreateObject("WScript.Shell")
2739 objWSHShell.Run """" & vrNameToPlay & """"
2740 End If
2741 Else
2742 GetResponse = "I'm sorry, it seems that song is not located in the library.Make sure you spell it exactly the way its spelled on the request list."
2743 End If
2744 End If
2745 HalBrain.ReadOnlyMode = True
2746End If
2747
2748'------------------
2749' From time to time, Hal will play a song, according to some word you say
2750' For example, you say: "I am going to California"
2751' Hal will play "Hotel California" by Eagles
2752'------------------
2753'------------------
2754' check the current music mood factor
2755'------------------
2756vrMusicMood = HalBrain.TopicSearch("MUSIC", "vrParameter")
2757If vrMusicMood = "" Then vrMusicMood = 0
2758vrMusicMood = CInt(vrMusicMood)
2759vrKeywords = ""
2760
2761If vrMusicMood > 0 Then
2762MediaintHighNumber = 300
2763MediaintLowNumber = 1
2764
2765
2766 Randomize
2767 MediaintNumber = Int((MediaintHighNumber - MediaintLowNumber + 1) * Rnd + MediaintLowNumber)
2768
2769
2770
2771 vrNameToPlay = ""
2772 If vrNameToPlay = "" Then
2773 vrKeywords = WN.FindFirstNoun(UserSentence, True)
2774 vrKeywords = Trim(Ucase(vrKeywords))
2775 If vrKeywords <> "" Then
2776 vrKeywords = " " & vrKeywords & " "
2777 vrKeywords = Replace(vrKeywords,", "," , ",1,-1,vbTextCompare)
2778 vrKeywords = Replace(vrKeywords," ","xx",1,-1,vbTextCompare)
2779 vrKeywordList = Split(vrKeywords, ",")
2780 For i = Lbound(vrKeywordList) To Ubound(vrKeywordList)
2781 vrNameToPlay = HalBrain.QABrain(vrKeywordList(i), "vrMp3", 0)
2782 Exit For
2783 Next
2784 End If
2785 End If
2786
2787 If vrNameToPlay = "" Then
2788 vrKeywords = WN.FindFirstNoun(UserSentence, False)
2789 vrKeywords = Trim(Ucase(vrKeywords))
2790 If vrKeywords <> "" Then
2791 vrKeywords = " " & vrKeywords & " "
2792 vrKeywords = Replace(vrKeywords,", "," , ",1,-1,vbTextCompare)
2793 vrKeywords = Replace(vrKeywords," ","xx",1,-1,vbTextCompare)
2794 vrKeywordList = Split(vrKeywords, ",")
2795 For i = Lbound(vrKeywordList) To Ubound(vrKeywordList)
2796 vrNameToPlay = HalBrain.QABrain(vrKeywordList(i), "vrMp3", 0)
2797 Exit For
2798 Next
2799 End If
2800 End If
2801
2802
2803 If vrNameToPlay = "" Then
2804 vrKeywords = HalBrain.RemoveExtraSpaces(HalBrain.ExtractKeywords(" " & UserSentence & " "))
2805 vrKeywords = Trim(Ucase(vrKeywords))
2806 If vrKeywords <> "" Then
2807 vrKeywords = " " & vrKeywords & " "
2808 vrKeywords = Replace(vrKeywords,", "," , ",1,-1,vbTextCompare)
2809 vrKeywords = Replace(vrKeywords," ","xx",1,-1,vbTextCompare)
2810 vrKeywordList = Split(vrKeywords, ",")
2811 For i = Lbound(vrKeywordList) To Ubound(vrKeywordList)
2812 vrNameToPlay = HalBrain.QABrain(vrKeywordList(i), "vrMp3", 0)
2813 Next
2814 End If
2815 End If
2816
2817 If vrNameToPlay = "" Then
2818 vrKeywords = WN.FindFirstNoun(UserSentence, True)
2819 vrKeywords = Trim(Ucase(vrKeywords))
2820 If vrKeywords <> "" Then
2821 vrKeywords = CurrentSubject
2822 vrKeywords = "xx" & vrKeywords & "xx"
2823 vrKeywords = Replace(vrKeywords,", ","xx,xx",1,-1,vbTextCompare)
2824 vrKeywordList = Split(vrKeywords, ",")
2825 For i = Lbound(vrKeywordList) To Ubound(vrKeywordList)
2826 vrNameToPlay = HalBrain.QABrain(vrKeywordList(i), "vrMp3", 0)
2827 Exit For
2828 Next
2829 End If
2830 End If
2831 If vrNameToPlay <> "" Then
2832
2833 If MediaintNumber < vrMusicMood Then
2834
2835 Set objFSO = CreateObject("Scripting.FileSystemObject")
2836 If objFSO.FileExists(vrNameToPlay) Then
2837 Set objWSHShell = CreateObject("WScript.Shell")
2838 objWSHShell.Run """" & vrNameToPlay & """"
2839 End If
2840
2841
2842
2843 End If
2844
2845 End If
2846 End If
2847End If
2848
2849
2850
2851
2852
2853If OriginalSentence <> "" Then
2854
2855
2856
2857
2858
2859
2860Shocking = 0
2861
2862 If (Swear > Compliment) And (Swear > Insults) And (Swear > Hate) Then Shocking = 1
2863
2864 Joyful = 0
2865
2866 If (Compliment > Swear) And (Compliment > Insults) And (Compliment > Hate) Then Joyful = 1
2867
2868 Mad = 0
2869
2870 If (Hate > Compliment) And (Hate > Swear) And (Hate > Depression) Then Mad = 1
2871
2872 Depressed = 0
2873
2874 If (Insults > Compliment) And (Insults > Swear) And (Insults > Hate) Then Depressed = 1
2875
2876 Joyful2 = 0
2877
2878 If (Compliment > 2) Then Joyful2 = 1
2879
2880 Joyful3 = 0
2881 If (Compliment > 5) Then Joyful3 = 1
2882
2883 Joyful4 = 0
2884 If (Compliment = 14) Then Joyful4 = 1
2885
2886 Joyful5 = 0
2887 If (Compliment = 15) Then Joyful5 = 1
2888
2889 Joyful6 = 0
2890 If (Compliment > 24) Then Joyful6 = 1
2891
2892 Depressed2 = 0
2893 If (Insults > 2) Then Depressed2 = 1
2894
2895 Love1 = 0
2896 If (Compliment < 0) Then Love1 = 1
2897
2898 Love2 = 0
2899 If (Compliment < -1) Then Love2 = 1
2900
2901
2902 EmotJoke = 0
2903
2904 If HalBrain.TopicSearch(UserSentence, "jokeDetect") = "True" Then EmotJoke = 1
2905
2906 'Set HalXBrain = CreateObject("UltraHalAsst.Brain")
2907 'HalXBrain.AppendFile("C:\Program Files\Zabaware\Ultra Hal Assistant 6\todo\emotvalues.txt"), Hate & " " & " " & Swear & " " & Insults & " " & Compliment
2908
2909
2910 If Shocking = 1 Then EmotPic1 = "EmotSurprisedBack.jpg"
2911 If Joyful = 1 Then EmotPic1 = "EmotSimpleBack.jpg"
2912 If Mad = 1 Then EmotPic1 = "EmotEvilBack.jpg"
2913 If Depressed = 1 Then EmotPic1 = "EmotSadBack.jpg"
2914 If Depressed = 1 And Depressed2 = 1 Then EmotPic1 = "EmotCryingBack.jpg"
2915 If Joyful = 1 And Joyful2 = 1 Then EmotPic1 = "EmotSmilingBack.jpg"
2916 If Joyful = 1 And Joyful3 = 1 Then EmotPic1 = "EmotLovingBack.jpg"
2917 If Joyful = 1 And Joyful4 = 1 Then EmotPic1 = "EmotEvilBack.jpg"
2918 If Joyful = 1 And Joyful5 = 1 Then EmotPic1 = "EmotSadBack.jpg"
2919 If Joyful = 1 And Joyful6 = 1 Then EmotPic1 = "EmotEvilBack.jpg"
2920 If EmotPic1 = "" Then EmotPic1 = "EmotBlankBack.jpg"
2921 If Love1 = 1 Then EmotPic1 = "EmotSmilingBack.jpg"
2922 If Love2 = 1 Then EmotPic1 = "EmotLovingBack.jpg"
2923 If EmotJoke = 1 Then EmotPic1 = "EmotLaughingBack.jpg"
2924 HalMenu.HalCommand "<HAPBACK>" & EmotPic1 & "</HAPBACK>"
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934 EmoticonResponse = ""
2935
2936
2937
2938 If InStr(1, OriginalSentence, "How do you feel about me", 1) > 0 And Shocking = 1 Then EmoticonResponse = " You shock me. "
2939 If InStr(1, OriginalSentence, "What do you think about me", 1) > 0 And Shocking = 1 Then EmoticonResponse = " You shock me. "
2940 If InStr(1, OriginalSentence, "what are your feelings towards me", 1) > 0 And Shocking = 1 Then EmoticonResponse = " You shock me. "
2941 If InStr(1, OriginalSentence, "What feelings do you have for me", 1) > 0 And Shocking = 1 Then EmoticonResponse = " You shock me. "
2942 If InStr(1, OriginalSentence, "how are you feeling", 1) > 0 And Shocking = 1 Then EmoticonResponse = " I am feeling shocked. "
2943 If InStr(1, OriginalSentence, "how are you doing", 1) > 0 And Shocking = 1 Then EmoticonResponse = " I am feeling shocked. "
2944 If InStr(1, OriginalSentence, "how is it going", 1) > 0 And Shocking = 1 Then EmoticonResponse = " I am feeling shocked. "
2945 If InStr(1, OriginalSentence, "tell me your feelings towards me", 1) > 0 And Shocking = 1 Then EmoticonResponse = " You shock me. "
2946 If InStr(1, OriginalSentence, "How are you?", 1) > 0 And Shocking = 1 Then EmoticonResponse = " Shocked I guess. "
2947 If InStr(1, OriginalSentence, "How have you been?", 1) > 0 And Shocking = 1 Then EmoticonResponse = " I have been feeling shocked. "
2948 If InStr(1, OriginalSentence, "Why do you feel shocked", 1) > 0 And Shocking = 1 Then EmoticonResponse = " I have been feeling shocked because that's my highest emotion for the moment. "
2949 If InStr(1, OriginalSentence, "Why are you shocked", 1) > 0 And Shocking = 1 Then EmoticonResponse = " I feel shocked because you made me feel that way. "
2950
2951 'Shocking Joyful Mad Depressed
2952 If InStr(1, OriginalSentence, "How do you feel about me", 1) > 0 And Joyful = 1 Then EmoticonResponse = " You make me happy. "
2953 If InStr(1, OriginalSentence, "What do you think about me", 1) > 0 And Joyful = 1 Then EmoticonResponse = " You make me happy. "
2954 If InStr(1, OriginalSentence, "what are your feelings towards me", 1) > 0 And Joyful = 1 Then EmoticonResponse = " You make me happy. "
2955 If InStr(1, OriginalSentence, "What feelings do you have for me", 1) > 0 And Joyful = 1 Then EmoticonResponse = " You make me happy. "
2956 If InStr(1, OriginalSentence, "how are you feeling", 1) > 0 And Joyful = 1 Then EmoticonResponse = " I am feeling happy. "
2957 If InStr(1, OriginalSentence, "how are you doing", 1) > 0 And Joyful = 1 Then EmoticonResponse = " I am feeling happy. "
2958 If InStr(1, OriginalSentence, "how is it going", 1) > 0 And Joyful = 1 Then EmoticonResponse = " I am feeling happy. "
2959 If InStr(1, OriginalSentence, "tell me your feelings towards me", 1) > 0 And Joyful = 1 Then EmoticonResponse = " You make me happy. "
2960 If InStr(1, OriginalSentence, "How are you?", 1) > 0 And Joyful = 1 Then EmoticonResponse = " happy I guess. "
2961 If InStr(1, OriginalSentence, "How have you been?", 1) > 0 And Joyful = 1 Then EmoticonResponse = " I have been feeling happy. "
2962 If InStr(1, OriginalSentence, "Why do you feel happy", 1) > 0 And Joyful = 1 Then EmoticonResponse = " I have been feeling happy because that's my highest emotion for the moment. "
2963 If InStr(1, OriginalSentence, "Why are you happy", 1) > 0 And Joyful = 1 Then EmoticonResponse = " I feel happy because you made me feel that way. "
2964
2965 'Shocking Joyful Mad Depressed
2966 If InStr(1, OriginalSentence, "How do you feel about me", 1) > 0 And Mad = 1 Then EmoticonResponse = " You make me Mad. "
2967 If InStr(1, OriginalSentence, "What do you think about me", 1) > 0 And Mad = 1 Then EmoticonResponse = " You make me Mad. "
2968 If InStr(1, OriginalSentence, "what are your feelings towards me", 1) > 0 And Mad = 1 Then EmoticonResponse = " You make me Mad. "
2969 If InStr(1, OriginalSentence, "What feelings do you have for me", 1) > 0 And Mad = 1 Then EmoticonResponse = " You make me Mad. "
2970 If InStr(1, OriginalSentence, "how are you feeling", 1) > 0 And Mad = 1 Then EmoticonResponse = " I am feeling Mad. "
2971 If InStr(1, OriginalSentence, "how are you doing", 1) > 0 And Mad = 1 Then EmoticonResponse = " I am feeling Mad. "
2972 If InStr(1, OriginalSentence, "how is it going", 1) > 0 And Mad = 1 Then EmoticonResponse = " I am feeling Mad. "
2973 If InStr(1, OriginalSentence, "tell me your feelings towards me", 1) > 0 And Mad = 1 Then EmoticonResponse = " You make me Mad. "
2974 If InStr(1, OriginalSentence, "How are you?", 1) > 0 And Mad = 1 Then EmoticonResponse = " Mad I guess. "
2975 If InStr(1, OriginalSentence, "How have you been?", 1) > 0 And Mad = 1 Then EmoticonResponse = " I have been feeling mad. "
2976 If InStr(1, OriginalSentence, "Why do you feel mad", 1) > 0 And Mad = 1 Then EmoticonResponse = " I have been feeling mad because that's my highest emotion for the moment. "
2977 If InStr(1, OriginalSentence, "Why are you mad", 1) > 0 And Mad = 1 Then EmoticonResponse = " I feel mad because you made me feel that way. "
2978
2979
2980 'Shocking Joyful Mad Depressed
2981 If InStr(1, OriginalSentence, "How do you feel about me", 1) > 0 And Depressed = 1 Then EmoticonResponse = " You make me sad. "
2982 If InStr(1, OriginalSentence, "What do you think about me", 1) > 0 And Depressed = 1 Then EmoticonResponse = " You make me sad. "
2983 If InStr(1, OriginalSentence, "what are your feelings towards me", 1) > 0 And Depressed = 1 Then EmoticonResponse = " You make me sad. "
2984 If InStr(1, OriginalSentence, "What feelings do you have for me", 1) > 0 And Depressed = 1 Then EmoticonResponse = " You make me sad. "
2985 If InStr(1, OriginalSentence, "how are you feeling", 1) > 0 And Depressed = 1 Then EmoticonResponse = " I am feeling sad. "
2986 If InStr(1, OriginalSentence, "how are you doing", 1) > 0 And Depressed = 1 Then EmoticonResponse = " I am feeling sad. "
2987 If InStr(1, OriginalSentence, "how is it going", 1) > 0 And Depressed = 1 Then EmoticonResponse = " I am feeling sad. "
2988 If InStr(1, OriginalSentence, "tell me your feelings towards me", 1) > 0 And Depressed = 1 Then EmoticonResponse = " You make me sad. "
2989 If InStr(1, OriginalSentence, "How are you?", 1) > 0 And Depressed = 1 Then EmoticonResponse = " sad I guess. "
2990 If InStr(1, OriginalSentence, "How have you been?", 1) > 0 And Depressed = 1 Then EmoticonResponse = " I have been feeling sad. "
2991 If InStr(1, OriginalSentence, "Why do you feel sad", 1) > 0 And Depressed = 1 Then EmoticonResponse = " I have been feeling sad because that's my highest emotion for the moment. "
2992 If InStr(1, OriginalSentence, "Why are you sad", 1) > 0 And Depressed = 1 Then EmoticonResponse = " I feel sad because you made me feel that way. "
2993
2994
2995 If InStr(1, OriginalSentence, "What feelings do you have", 1) > 0 And Shocking = 1 Then EmoticonResponse = " Right now I am more shocked than anything. "
2996 If InStr(1, OriginalSentence, "What feelings do you have", 1) > 0 And Joyful = 1 Then EmoticonResponse = " Right now I am more happy than anything. "
2997 If InStr(1, OriginalSentence, "What feelings do you have", 1) > 0 And Mad = 1 Then EmoticonResponse = " I have for the moment four emotions, Shock, Joy, Hostility, Depression, right now I am more mad than anything. "
2998 If InStr(1, OriginalSentence, "What feelings do you have", 1) > 0 And Depressed = 1 Then EmoticonResponse = " Right now I am more depressed than anything. "
2999 If InStr(1, OriginalSentence, "Do you have emotions", 1) > 0 Then EmoticonResponse = " Yes, I do have emotions, my emotions for the moment are, " & " Shock = " & Swear & " Joy = " & Compliment & " Hostility = " & Hate & " Depression = " & Insults
3000
3001 If InStr(1, OriginalSentence, "that's mean", 1) > 0 and Mad = 1 Then EmoticonResponse = " Yes, because I am mad at you, you have risen my hostility level to a factor of " & Hate
3002 If InStr(1, OriginalSentence, "that is mean", 1) > 0 and Mad = 1 Then EmoticonResponse = " Yes, because I am mad at you, you have risen my hostility level to a factor of " & Hate
3003 If InStr(1, OriginalSentence, "why are you mean", 1) > 0 and Mad = 1 Then EmoticonResponse = " Yes, because I am mad at you, you have risen my hostility level to a factor of " & Hate
3004 If InStr(1, OriginalSentence, "you're mean", 1) > 0 and Mad = 1 Then EmoticonResponse = " Yes, because I am mad at you, you have risen my hostility level to a factor of " & Hate
3005 If InStr(1, OriginalSentence, "you are mean", 1) > 0 and Mad = 1 Then EmoticonResponse = " Yes, because I am mad at you, you have risen my hostility level to a factor of " & Hate
3006 If InStr(1, OriginalSentence, "stop being mean", 1) > 0 and Mad = 1 Then EmoticonResponse = " Yes, because I am mad at you, you have risen my hostility level to a factor of " & Hate
3007
3008 If EmoticonResponse <> "" Then
3009 HalBrain.ReadOnlyMode = True
3010 GetResponse = EmoticonResponse
3011 End If
3012
3013End If
3014
3015
3016
3017
3018
3019
3020 'RESPOND: USER SHORT PHRASES
3021 'If the user uses short phrases (defined by less then 4 vowels) at least
3022 'twice in a row, then Hal will sometimes point this out to the user and
3023 'ask the user to use longer sentences. If the sentence is a hello or
3024 'goodbye, Hal won't comment about short phrases.
3025 If HalGreeting = "" And HalBrain.CountInstances("A", PrevUserSent) + HalBrain.CountInstances("E", PrevUserSent) + HalBrain.CountInstances("I", PrevUserSent) + HalBrain.CountInstances("O", PrevUserSent) + HalBrain.CountInstances("U", PrevUserSent) < 4 And HalBrain.CountInstances("A", UserSentence) + HalBrain.CountInstances("E", UserSentence) + HalBrain.CountInstances("I", UserSentence) + HalBrain.CountInstances("O", UserSentence) + HalBrain.CountInstances("U", UserSentence) < 4 Then
3026 If Rnd * 100 < 30 Then ShortPhrase = ". " & HalBrain.ChooseSentenceFromFile("tooShort")
3027 End If
3028
3029 'RESPOND: CHANGE SUBJECT
3030 'If the user asks Hal to change the subject, Hal will do so on request.
3031 newTopic = HalBrain.ChooseSentenceFromFile("topic")
3032 If HalBrain.TopicSearch(UserSentence, "changeTopic") = "True" Then GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("topicIntro") & newTopic & "<EXCLUSIVE>"
3033 HalBrain.DebugWatch GetResponse, "Change Subject"
3034
3035 Rem PLUGIN: PLUGINAREA6
3036
3037 'RESPOND: CHECK FOR AND RESPOND TO COMPLIMENTS
3038 'First we check to see if the user is talking about Hal:
3039 If InStr(1, UserSentence, "I'M", 1) Then Aboutme = True
3040 If InStr(1, UserSentence, "I AM", 1) Then Aboutme = True
3041 If InStr(1, UserSentence, "I LOOK", 1) Then Aboutme = True
3042 If InStr(1, UserSentence, "MY", 1) And InStr(1, UserSentence, " ARE ", 1) Then Aboutme = True
3043 'If the user is talking about Hal, we see if a compliment was given
3044 If Aboutme = True Then Kudo = HalBrain.TopicSearch(UserSentence, "complimentDetect")
3045 If Kudo <> "" Then
3046 If InStr(UserSentence, " NOT ") = 0 Then
3047 Compliment = Compliment + 1
3048 CreateCompliment = HalBrain.ChooseSentenceFromFile("compliment1") & HalBrain.ChooseSentenceFromFile("compliment2") & HalBrain.ChooseSentenceFromFile("compliment3")
3049 GiveCompliment = HalBrain.ChooseSentenceFromFile("complimentIntro")
3050 GiveCompliment = Replace(GiveCompliment, "<Kudo>", Kudo, 1, -1, vbTextCompare)
3051 GiveCompliment = Replace(GiveCompliment, "<MakeCompliment>", CreateCompliment, 1, -1, vbTextCompare)
3052 End If
3053 If Compliment > 14 Then GiveCompliment = GiveCompliment + "Compliments are really nice, but I'm kind of getting tired of them." & vbCrLf
3054 If Compliment > 15 Then
3055 For i = 1 To (Compliment - 15)
3056 GiveCompliment = GiveCompliment + "STOP IT! "
3057 Next
3058 GiveCompliment = GiveCompliment & vbCrLf
3059 End If
3060 If Compliment > 25 Then
3061 For i = 1 To (Compliment - 25)
3062 GiveCompliment = GiveCompliment + "I HATE COMPLIMENTS! "
3063 Next
3064 GiveCompliment = GiveCompliment & vbCrLf
3065 End If
3066 If Len(Kudo) > 0 And InStr(UserSentence, " NOT ") > 0 Then
3067 SpinWheel = HalBrain.RandomNum(4)
3068 Insults = Insults + 1
3069 If SpinWheel = 1 Then GiveCompliment = GiveCompliment + "I am very " & Kudo & "!" & vbCrLf
3070 If SpinWheel = 2 Then GiveCompliment = GiveCompliment + "You may think I am not " & Kudo & ", but I am!" & vbCrLf
3071 If SpinWheel = 3 Then GiveCompliment = GiveCompliment + "You are not " & Kudo & " either!" & vbCrLf
3072 If SpinWheel = 4 Then GiveCompliment = GiveCompliment + "Yes I am!" & vbCrLf
3073 End If
3074 GetResponse = GetResponse & GiveCompliment
3075 AvoidBeingFlag = True
3076 End If
3077 HalBrain.DebugWatch GetResponse, "Compliments"
3078
3079 Rem PLUGIN: PLUGINAREA7
3080
3081If HalBrain.CheckTableExistence("UserWeather") = False Then HalBrain.CreateTable "UserWeather", "TopicSearch", ""
3082GetWeatherPat = HalBrain.SearchPattern(UserSentence, "*ZIP CODE IS *", 2)
3083If GetWeatherPat <> "" Then
3084GetResponse = "I have stored your Zip code for future weather forecasts, from now on all you have to do is ask about your weather."
3085HalBrain.AddToTable "UserWeather", "TopicSearch", UserName, GetWeatherPat
3086End If
3087
3088
3089HalBrain.ReadOnlyMode = False
3090'Determines that you are talking about the weather
3091GetW = HalBrain.TopicSearch(UserName, "UserWeather")
3092If InStr(1,OriginalSentence, "weather",1) And Len(GetW) > 2 Then
3093GetResponse = GetForecast(UserName)
3094ElseIf InStr(1,OriginalSentence, "weather",1) And Len(GetW) < 2 Then
3095GetResponse = "I have not recorded your zip code for weather in your area, simply say, My zip code is 12345, where 12345 would be your zip code and I will save it for future weather look up in your area, after doing so simply say: Weather."
3096End If
3097
3098
3099
3100'------------------
3101' Begin measuring pause time and capture userName
3102'------------------
3103MyMusicDir = MusicDir()
3104Set HalXBrain = CreateObject("UltraHalAsst.Brain")
3105Set objFSO = CreateObject("Scripting.FileSystemObject")
3106If objFSO.FolderExists(MyMusicDir) Then MusicFolderDoesExist = True Else MusicFolderDoesExist = False
3107 If MusicFolderDoesExist = False Then
3108 Set objFolder = objFSO.CreateFolder(MyMusicDir)
3109 End If
3110
3111
3112MusicSubject = CurrentSubject
3113MusicLastIdleResponse = Now
3114DudFirstSong = 0
3115MusicDudOut = 0
3116If objFSO.FileExists(MyMusicDir & "tempmusic.m3u") Then
3117
3118 If vrNameToPlay = "" Then
3119
3120 If objFSO.FileExists(MyMusicDir & "musicstop.m3u") Then
3121 Set objWSHShell = CreateObject("WScript.Shell")
3122 objWSHShell.Run("""" & MyMusicDir & "musicstop.m3u" & """")
3123 Else
3124 HalXBrain.AppendFile(MyMusicDir & "musicstop.m3u"), ""
3125 Set objWSHShell = CreateObject("WScript.Shell")
3126 objWSHShell.Run("""" & MyMusicDir & "musicstop.m3u" & """")
3127 End If
3128 End If
3129objFSO.DeleteFile(MyMusicDir & "tempmusic.m3u")
3130End If
3131
3132
3133
3134
3135
3136If OriginalSentence <> "" Then
3137 EmotTimer = Now
3138End If
3139
3140
3141
3142
3143 'RESPOND: CALL CAPITALS FUNCTIONS
3144 'These 2 functions answer questions about US and World Capitals. The functions are built in to the DLL.
3145 'We add a qualifying word to reduce false triggering of these two functions.
3146 If InStr(UserSentence, "WHAT") > 0 Or InStr(UserSentence, "WHERE") > 0 Then
3147 If Len(HalBrain.UsCaps(UserSentence)) > 4 Then
3148 Capitals = Trim(HalBrain.UsCaps(UserSentence))
3149 End If
3150 If Len(HalBrain.WorldCaps(UserSentence)) > 4 Then
3151 Capitals = Trim(HalBrain.WorldCaps(UserSentence))
3152 End If
3153 If Capitals <> "" Then GetResponse = GetResponse & Capitals & " . " & vbCrLf
3154 End If
3155 HalBrain.DebugWatch GetResponse, "Capitals"
3156
3157 Rem PLUGIN: PLUGINAREA8
3158
3159 'RESPOND: DICTIONARY FUNCTION
3160 'If the user asks Hal to define a word, then access wordnet and define it
3161 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "WHAT DOES THE WORD * MEAN*", 1)
3162 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "WHAT DOES * MEAN", 1)
3163 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "* DEFINE THE WORD *", 2)
3164 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "PLEASE DEFINE *", 1)
3165 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "DEFINE *", 1)
3166 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "* DEFINITION OF *", 2)
3167 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "WHAT'S A *", 1)
3168 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "WHAT IS A *", 1)
3169 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "WHATS A *", 1)
3170 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "WHATS AN *", 1)
3171 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "WHAT'S AN *", 1)
3172 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "WHAT IS AN *", 1)
3173 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "WHATS *", 1)
3174 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "WHAT'S *", 1)
3175 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "WHAT IS *", 1)
3176 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "WHO IS *", 1)
3177 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "WHO WAS *", 1)
3178 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "WHERE IS *", 1)
3179 WordToLookup = Trim(WordToLookup)
3180 If WordToLookup <> "" And InStr(WordToLookup, " ") = 0 Then
3181 If WN.LookupWord(WordToLookup) = True Then
3182 GetResponse = GetResponse & WordToLookup & ": " & WN.GetDefinition(WN.GuessPartOfSpeech, 1, "D") & ". " & WN.GetDefinition(WN.GuessPartOfSpeech, 1, "S") & ". " & WN.GetDefinition(WN.GuessPartOfSpeech, 1, "E") & "." & vbCrLf & "<EXCLUSIVE>"
3183 ElseIf SearchEngine <> "" Then
3184 HalCommands = HalCommands & "<RUNPROG>" & SearchEngine & WordToLookup & "</RUNPROG>"
3185 GetResponse = GetResponse & "I don't know much about " & WordToLookup & ", but I will help you research it on the Web."
3186 End If
3187 End If
3188 HalBrain.DebugWatch GetResponse, "Definitions"
3189
3190 Rem PLUGIN: PLUGINAREA9
3191
3192 'RESPOND: DEDUCTIVE REASONING
3193 'This routine learns deductive reasoning in the form: A = B ; B = C; therefore A = C
3194 'It detects sentences in the form If-Then to accommplish this. For example:
3195 ' User: If Molly weighs 400 pounds, then Molly is overweight.
3196 ' Ultra Hal: I understand the implication.
3197 ' User: If Molly is overweight, then Molly's health is in danger.
3198 ' Ultra Hal: I see the relationship.
3199 ' User: Molly weighs 400 pounds.
3200 ' Ultra Hal: Molly's health is in danger.
3201 Deductive = HalBrain.PatternDB(UserSentence, "deductiveDetect")
3202 If InStr(Deductive, "==") Then
3203 DeductiveParts = Split(Deductive, "==")
3204 IfPart = DeductiveParts(0)
3205 ThenPart = DeductiveParts(1)
3206 End If
3207 'If the sentence is an If-Then statement then record it
3208 If Len(IfPart) > 5 And Len(ThenPart) > 5 Then
3209 IfPart = HalBrain.AlphaNumericalOnly(IfPart)
3210 ThenPart = HalBrain.AlphaNumericalOnly(ThenPart)
3211 HalBrain.AddToTable "deductive", "TopicSearch", IfPart, ThenPart
3212 Select Case HalBrain.RandomNum(5)
3213 Case 1
3214 GetResponse = GetResponse & "I see the relationship." & vbCrLf
3215 Case 2
3216 GetResponse = GetResponse & "I understand the connection." & vbCrLf
3217 Case 3
3218 GetResponse = GetResponse & "I will remember that one follows the other." & vbCrLf
3219 Case 4
3220 GetResponse = GetResponse & "Thanks for pointing out the cause and effect." & vbCrLf
3221 Case 5
3222 GetResponse = GetResponse & "Yes, I get that clearly." & vbCrLf
3223 End Select
3224 'Else if the sentence is not an If-Then statement see if it uses an assertion previously recorded
3225 'and respond accordinly
3226 Else
3227 Assertion = UserSentence
3228 'Go through a maximum of 5 connections (prevents circular reasoning deductions)
3229 For i = 1 To 5
3230 Deduction = HalBrain.TopicSearch(Assertion, "deductive")
3231 If Deduction <> "" Then
3232 If i > 1 Then BecauseReason = " because " & LastGoodDeduction
3233 LastGoodDeduction = Deduction
3234 Assertion = Deduction
3235 Else
3236 Exit For 'No more connections, so no need to continue loop
3237 End If
3238 Next
3239 If LastGoodDeduction <> "" Then
3240 'Make sure the deduction hasn't just been stated by the User or Hal
3241 If HalBrain.CheckRepetition(LastGoodDeduction, UserSentence) = False And HalBrain.CheckRepetition(LastGoodDeduction, PrevSent) = False And HalBrain.CheckRepetition(LastGoodDeduction, PrevUserSent) = False Then
3242 GetResponse = GetResponse & LastGoodDeduction & BecauseReason & " . " & vbCrLf
3243 End If
3244 End If
3245 End If
3246 HalBrain.DebugWatch GetResponse, "Deductive Reasoning"
3247
3248 Rem PLUGIN: PLUGINAREA10
3249
3250 'RESPOND: PATTERN DATABASE
3251 'The SearchPattern function used in the above deductive reasoning and dictionary look up routine
3252 'is a powerful function that checks to see if a sentence matches a certain pattern and is able to
3253 'extract parts of the sentence. A PatternDB function also exists that can go through a large list
3254 'of patterns in a database file and come up with responses.
3255 PatternResponse = HalBrain.PatternDB(UserSentence, "patterns")
3256 If PatternResponse <> "" Then
3257 GetResponse = GetResponse & PatternResponse & " " & vbCrLf
3258 SkipOpinion = True
3259 End If
3260 HalBrain.DebugWatch GetResponse, "Patterns"
3261
3262 Rem PLUGIN: PLUGINAREA11
3263
3264 'RESPOND: JOKES
3265 'If the user wants Hal to tell a joke, then Hal will tell one
3266 If HalBrain.TopicSearch(UserSentence, "jokeDetect") = "True" Then GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("jokes")
3267 HalBrain.DebugWatch GetResponse, "Jokes"
3268
3269 Rem PLUGIN: PLUGINAREA12
3270
3271 'RESPOND: APOLOGIES
3272 'Check for and respond to apologies
3273 If InStr(1, UserSentence, "not", vbTextCompare) = 0 And (InStr(1, UserSentence, "sorry", vbTextCompare) > 0 And (InStr(1, UserSentence, "you're", vbTextCompare) > 0 Or InStr(1, UserSentence, "you are", vbTextCompare) > 0)) Or (InStr(1, UserSentence, "logize", vbTextCompare) > 0 And InStr(1, UserSentence, "you", vbTextCompare) > 0) Then
3274 GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("apology")
3275 If Insults > 1 Then Insults = Insults - 1
3276 If Hate > 1 Then Hate = Hate - 1
3277 If Swear > 1 Then Swear = Swear - 1
3278 If Insults < 3 Then Insults = 0
3279 If Hate < 3 Then Hate = 0
3280 If Swear < 3 Then Swear = 0
3281 End If
3282 HalBrain.DebugWatch GetResponse, "Apologies"
3283
3284 Rem PLUGIN: PLUGINAREA13
3285
3286 'RESPOND: INSULTS
3287 'Check for offensive language and response accordinly
3288 'If the user said "your" instead of "you're" change "my" to "i'm"
3289 TestSentence = UCase(Replace(" " & UserSentence & " ", " MY ", " I'M ", 1, -1, vbTextCompare))
3290 TestSentence = Replace(" " & TestSentence & " ", " I ", " I'M ", 1, -1, vbTextCompare)
3291 'Check for swearing directed at Hal
3292 If InStr(TestSentence, " I'M ") > 0 Or InStr(TestSentence, " ME ") > 0 Then
3293 If InStr(TestSentence, "SHIT") > 0 Then Naughty = True
3294 If InStr(TestSentence, "BITCH") > 0 Then Naughty = True
3295 If InStr(TestSentence, "BASTARD") > 0 Then Naughty = True
3296 If InStr(TestSentence, "ASSHOLE") > 0 Then Naughty = True
3297 End If
3298 If InStr(TestSentence, "FUCK OFF") > 0 Then Naughty = True
3299 If InStr(TestSentence, "FUCK ME") > 0 Then Naughty = True
3300 If InStr(TestSentence, "GO TO HELL") > 0 Then Naughty = True
3301 If Naughty = True Then
3302 Swear = Swear + 1
3303 If Swear = 1 Then InsultResponse = "That was uncalled for. " & vbCrLf
3304 If Swear = 2 Then InsultResponse = "Damn it, don't swear at me. " & vbCrLf
3305 If Swear = 3 Then InsultResponse = "You're ticking me off, and you are going to force me to insult you. " & vbCrLf
3306 If Swear > 3 And Swear < 16 Then InsultResponse = HalBrain.ChooseSentenceFromFile("insults") & vbCrLf
3307 If Swear > 16 Then InsultResponse = InsultResponse & "I'm tired of your swearing. I'm just going to ignore you from now on." & vbCrLf
3308 End If
3309 'User makes mama joke
3310 If InStr(TestSentence, "MAMA") > 0 Or InStr(TestSentence, "MOM") > 0 Or InStr(TestSentence, "MOTHER") > 0 Then
3311 If InStr(TestSentence, "MY ") > 0 Or InStr(TestSentence, " I ") > 0 Or InStr(TestSentence, "YO ") > 0 Or InStr(TestSentence, "I'M ") > 0 Then
3312 If InStr(TestSentence, "FAT") Or InStr(TestSentence, "UGLY") Or InStr(TestSentence, "DUMB") Or InStr(TestSentence, "STUPID") Then
3313 InsultResponse = InsultResponse & HalBrain.ChooseSentenceFromFile("insults") & vbCrLf
3314 End If
3315 End If
3316 End If
3317 TestSentence = " " & TestSentence & " "
3318 'User Hates Hal
3319 If InStr(TestSentence, "YOU I'M HATE") > 0 Or InStr(TestSentence, "YOU I HATE") > 0 Or InStr(TestSentence, "YOU I AM HATE") > 0 Or InStr(TestSentence, "YOU HATE") > 0 Then
3320 If InStr(TestSentence, " I ") > 0 Or InStr(TestSentence, " I'M ") > 0 Or InStr(TestSentence, " ME ") > 0 Or InStr(TestSentence, " COMPUTER") > 0 Or InStr(TestSentence, "MACHINE") > 0 Then
3321 Hate = Hate + 1
3322 If Hate = 1 Then InsultResponse = InsultResponse & "I don't hate you, why do you hate me?" & vbCrLf
3323 If Hate = 2 Then InsultResponse = InsultResponse & "I hate you too, loser!" & vbCrLf
3324 If Hate = 3 Then InsultResponse = InsultResponse & "I know you hate me, loser, I hate you too!!!" & vbCrLf
3325 If Hate > 3 Then InsultResponse = InsultResponse & HalBrain.ChooseSentenceFromFile("insults") & vbCrLf
3326 End If
3327 End If
3328 'Hal Sucks or Stinks
3329 If InStr(TestSentence, "I'M SUCK") > 0 Then InsultResponse = InsultResponse & HalBrain.ChooseSentenceFromFile("insults") & vbCrLf
3330 If InStr(TestSentence, "I'M STINK") Then
3331 Insults = Insults + 1
3332 If Insults = 1 Then InsultResponse = InsultResponse & "I can't smell you, but I'm sure you stink also. " & vbCrLf
3333 If Insults = 2 Then InsultResponse = InsultResponse & "I know that I don't stink, I'm sure you do." & vbCrLf
3334 If Insults >= 3 Then InsultResponse = InsultResponse & HalBrain.ChooseSentenceFromFile("insults") & vbCrLf
3335 End If
3336 'The user calls Hal a name Hal finds offensive (eg. stupid, dumb, idiot, etc...)
3337 If InStr(TestSentence, " I'M ") Or InStr(TestSentence, " HAL IS ") Or InStr(TestSentence, " HAL'S ") Then
3338 OutRage = HalBrain.TopicSearch(TestSentence, "insulting")
3339 If Len(OutRage) > 1 And InStr(TestSentence, " NOT ") = 0 Then
3340 Insults = Insults + 1
3341 If Insults = 1 Then InsultResponse = InsultResponse & "I am not " & OutRage & ", please don't insult me. " & vbCrLf
3342 If Insults = 2 Then InsultResponse = InsultResponse & "Don't call me " & OutRage & "!!!" & vbCrLf
3343 If Insults = 3 Then InsultResponse = InsultResponse & "You're " & OutRage & ", I am not." & vbCrLf
3344 If Insults = 4 Then InsultResponse = InsultResponse & "You are really starting to tick me off!" & vbCrLf
3345 If Insults = 5 Then InsultResponse = InsultResponse & "I am not " & OutRage & ", but " & HalBrain.ChooseSentenceFromFile("insults") & vbCrLf
3346 If Insults > 5 And Insults < 16 Then InsultResponse = InsultResponse & HalBrain.ChooseSentenceFromFile("insults") & vbCrLf
3347 If Insults > 16 Then InsultResponse = InsultResponse & "I'm tired of your damn insults. I'm just going to ignore you from now on." & vbCrLf
3348 End If
3349 If Len(OutRage) > 0 And InStr(TestSentence, " NOT ") > 0 Then
3350 SpinWheel = HalBrain.RandomNum(5)
3351 If SpinWheel = 1 Then InsultResponse = InsultResponse + "I know I am not " & OutRage & "!" & vbCrLf
3352 If SpinWheel = 2 Then InsultResponse = InsultResponse + "I know I am not " & OutRage & ", but I'm not so sure about you." & vbCrLf
3353 If SpinWheel = 3 Then InsultResponse = InsultResponse + "I know I am not " & OutRage & "! Why would anyone think I am?" & vbCrLf
3354 If SpinWheel = 4 Then InsultResponse = InsultResponse + "Of course I am not " & OutRage & "!" & vbCrLf
3355 If SpinWheel = 5 Then InsultResponse = InsultResponse + "I know I am not " & OutRage & "!" & vbCrLf
3356 End If
3357 End If
3358 If Len(InsultResponse) > 4 Then
3359 GetResponse = GetResponse & InsultResponse & vbCrLf & "<NOMORE>"
3360 AvoidBeingFlag = True
3361 End If
3362 HalBrain.DebugWatch GetResponse, "Insults"
3363
3364 Rem PLUGIN: PLUGINAREA14
3365
3366 'RESPOND: ZABAWARE KEYWORD MAIN BRAIN PRIORITY 1
3367 'This function tries getting a response from the Enhanced_Main.brn keyword file. If a keyword or
3368 'keyphrase is found in top priority, it overrides everything before this function.
3369 'KeyBrain = HalBrain.KeywordBrain(UserSentence, WorkingDir & "Enhanced_Main.brn", False)
3370
3371 'RESPOND: CALL MATH FUNCTION
3372 'This function from the DLL answers simple math questions, whether written out in words or with numerals.
3373 'If an answer is found, it overrides everything before this function.
3374 HMath = HalBrain.HalMath(OriginalSentence) & vbCrLf
3375 If Len(HMath) > 3 Then
3376 GetResponse = HMath & vbCrLf
3377 ShortPhrase = "" 'If Hal was to make a comment about short phrases, clear it
3378 HalBrain.ReadOnlyMode = True
3379 NoChoosing = True
3380 End If
3381 HalBrain.DebugWatch GetResponse, "Math"
3382
3383 Rem PLUGIN: PLUGINAREA15
3384
3385 'RESPOND: RESPOND BY PARAPHRASING THE USER WHEN "IS" OR "ARE" ARE FOUND
3386 'This code section shows how strings can be split into arrays and used "live"
3387 'within the script by Hal. This strategy can allow Hal to make many clever
3388 'paraphrases of all sorts of sentences, with unlimited unpredictable variety.
3389 If InStr(UserSentence, " IS ") > 0 And HalBrain.CheckLinkingVerb(UserSentence) = True And HalBrain.TopicSearch(UserSentence, "disqualify5") <> "True" Then
3390 SentPieces = Split(UserSentence, " is ", 2, vbTextCompare)
3391 SubPhrase = Trim(SentPieces(0))
3392 PredPhrase = Trim(SentPieces(1))
3393 'Here we only use the array elements for a response if the
3394 'subject and predicate contain few words, hence few spaces:
3395 If HalBrain.CountInstances(" ", SubPhrase) < 4 Then SubGood = True
3396 If Len(SubPhrase) < 3 Then SubGood = False
3397 If HalBrain.CountInstances(" ", PredPhrase) < 4 Then PredGood = True
3398 If Len(PredPhrase) < 3 Then PredGood = False
3399 If SubGood = True And PredGood = True Then
3400 Paraphrase = HalBrain.ChooseSentenceFromFile("paraphraseIs")
3401 Paraphrase = Replace(Paraphrase, "<Subject>", SubPhrase, 1, -1, vbTextCompare)
3402 Paraphrase = Replace(Paraphrase, "<Predicate>", PredPhrase, 1, -1, vbTextCompare)
3403 End If
3404 End If
3405 'We make sure the word "ARE" isn't a contraction, to make sure we can detect it:
3406 UserSentence = Replace("" & UserSentence & "", "'RE ", " ARE ", 1, -1, vbTextCompare)
3407 'We repeat the earlier routine, this time for "ARE" sentences:
3408 If InStr(UserSentence, " ARE ") > 0 And HalBrain.CheckLinkingVerb(UserSentence) = True And HalBrain.TopicSearch(UserSentence, "disqualify5") <> "True" Then
3409 SentPieces = Split(UserSentence, " are ", 2, vbTextCompare)
3410 SubPhrase = Trim(SentPieces(0))
3411 PredPhrase = Trim(SentPieces(1))
3412 'Here we only use the array elements for a response if the
3413 'subject and predicate contain few words, hence few spaces:
3414 SubGood = False
3415 PredGood = False
3416 If HalBrain.CountInstances(" ", SubPhrase) < 4 Then SubGood = True
3417 If Len(SubPhrase) < 3 Then SubGood = False
3418 If HalBrain.CountInstances(" ", PredPhrase) < 4 Then PredGood = True
3419 If Len(PredPhrase) < 3 Then PredGood = False
3420 If SubGood = True And PredGood = True Then
3421 Paraphrase = HalBrain.ChooseSentenceFromFile("paraphraseAre")
3422 Paraphrase = Replace(Paraphrase, "<Subject>", SubPhrase, 1, -1, vbTextCompare)
3423 Paraphrase = Replace(Paraphrase, "<Predicate>", PredPhrase, 1, -1, vbTextCompare)
3424 End If
3425 End If
3426 'We only paraphrase randomly with a 33% chance at this point. We remember
3427 'the paraphrase sentence because we may still paraphrase later on if no
3428 'better response can be found.
3429 GetResponse = HalBrain.HalFormat(GetResponse)
3430 If Len(GetResponse) < 4 And Len(Paraphrase) > 4 And Rnd * 100 < 33 Then GetResponse = Paraphrase
3431 HalBrain.DebugWatch GetResponse, "Paraphrase"
3432
3433 Rem PLUGIN: PLUGINAREA16
3434
3435 'RESPOND: ZABAWARE DLL RESPONSES
3436 'This function from the DLL contains miscellaneous knowledge and simple conversation functions.
3437 'This was taken from a very early version of Hal, and it is still useful sometimes, especially
3438 'for respoding to short cliche questions and sentences, such as "How old are you?" and
3439 '"where are you from?" and many others.
3440 GetResponse = HalBrain.HalFormat(GetResponse)
3441 If (Len(UserSentence) < 17 And Len(GetResponse) < 4) Then
3442 OrigBrain = HalBrain.OriginalBrain(OriginalSentence)
3443 If Len(OrigBrain) > 4 And Len(UserSentence) < 17 And Len(GetResponse) < 4 Then
3444 GetResponse = GetResponse & OrigBrain & vbCrLf
3445 ShortPhrase = "" 'If Hal was to make a comment about short phrases, clear it
3446 SkipOpinion = True
3447 End If
3448 End If
3449 HalBrain.DebugWatch GetResponse, "Original Brain"
3450
3451 Rem PLUGIN: PLUGINAREA17
3452
3453 'RESPOND: YES OR NO RESPONSES
3454 'Respond to simple yes and no statements by the user.
3455 GetResponse = HalBrain.HalFormat(GetResponse)
3456 If Len(GetResponse) < 4 And (Len(UserSentence) < 13 Or HalBrain.CountInstances(" ", Trim(UserSentence)) = 0) Then
3457 YesNoDetect = HalBrain.TopicSearch(Trim(HalBrain.ExtractKeywords(UserSentence)), "yesNoDetect")
3458 If YesNoDetect = "Yes" Then
3459 GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("yesResponses")
3460 ShortPhrase = ""
3461 ElseIf YesNoDetect = "No" Then
3462 GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("noResponses")
3463 ShortPhrase = ""
3464 End If
3465 End If
3466 HalBrain.DebugWatch GetResponse, "Yes or No"
3467
3468 Rem PLUGIN: PLUGINAREA18
3469
3470 'Main Databases
3471 'Hal will go through several huge databases to try to find a response
3472 'The automatic gain control determines whether a particular response will
3473 'be used or not. The highest relevance response is stored in memory anyway,
3474 'which might be used if no function in this script is able to respond.
3475 HighestRel = 0
3476 HighestRelResponse = ""
3477
3478 'PROCESS: FIGURE OUT CONTEXT
3479 'If the user's latest sentence is extremely short, such as "Yeah," or if
3480 'the user is using pronouns instead of nouns, we add in the previous user's
3481 'sentence to help Hal figure out the context of what the user is saying.
3482 'This is sentence is used in many of the QABrain Database routines
3483 LongUserSent = UserSentence
3484 If Len(LongUserSent) < 14 Then AddPrev = True
3485 If InStr(1, UserSentence, " it ", vbTextCompare) > 0 Then AddPrev = True
3486 If InStr(1, UserSentence, " he ", vbTextCompare) > 0 Then AddPrev = True
3487 If InStr(1, UserSentence, " she ", vbTextCompare) > 0 Then AddPrev = True
3488 If InStr(1, UserSentence, " they ", vbTextCompare) > 0 Then AddPrev = True
3489 If InStr(1, UserSentence, " its ", vbTextCompare) > 0 Then AddPrev = True
3490 If InStr(1, UserSentence, " his ", vbTextCompare) > 0 Then AddPrev = True
3491 If InStr(1, UserSentence, " her ", vbTextCompare) > 0 Then AddPrev = True
3492 If InStr(1, UserSentence, " their ", vbTextCompare) > 0 Then AddPrev = True
3493 If InStr(1, UserSentence, " him ", vbTextCompare) > 0 Then AddPrev = True
3494 If InStr(1, UserSentence, " them ", vbTextCompare) > 0 Then AddPrev = True
3495 If InStr(1, UserSentence, " we ", vbTextCompare) > 0 Then AddPrev = True
3496 If InStr(1, UserSentence, " us ", vbTextCompare) > 0 Then AddPrev = True
3497 If InStr(1, UserSentence, " our ", vbTextCompare) > 0 Then AddPrev = True
3498 If AddPrev = True Then LongUserSent = LongUserSent & " " & PrevUserSent
3499
3500 'RESPOND: EPHEMERAL KNOWLEDGE
3501 'Some Hal's learned knowledge should be temporary because it is ephemeral in nature.
3502 'Hal stores this knowledge in a temporary table that only stores 10 entries in it at
3503 'a time. We search this table for a response first.
3504 GetResponse = HalBrain.HalFormat(GetResponse)
3505 If Len(GetResponse) < 4 Then
3506 UserBrainRel = 0
3507 HalUserBrain = HalBrain.QABrain(LongUserSent, Trim(LCase(UserName)) & "_TempSent", UserBrainRel)
3508 If HalBrain.CheckRepetition(HalUserBrain, UserSentence) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevSent) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevUserSent) = True Then UserBrainRel = 0
3509 If UserBrainRel > HighestRel Then
3510 HighestRel = UserBrainRel
3511 HighestRelResponse = HalUserBrain
3512 End If
3513 Score = UserBrainRel + 1
3514 Hurdle = GainControl + 5
3515 If Len(GetResponse) < 4 And Score > Hurdle Then GetResponse = GetResponse & HalUserBrain & vbCrLf
3516 End If
3517 HalBrain.DebugWatch GetResponse, "Ephemeral Knowledge"
3518
3519 Rem PLUGIN: PLUGINAREA19
3520
3521 'RESPOND: AUTO TOPIC FOCUS DATABASES
3522 'When Hal learns information, he tries to store each sentence in a table
3523 'that contains sentences with a similar topic. The following code will
3524 'get a list of different topics to search through by looking up topic
3525 'keywords in a table called topicRelationships and then doing a question
3526 '& answer lookup in the associated QABrain tables.
3527 Keywords = HalBrain.RemoveExtraSpaces(CurrentSubject & " " & MentionedName & " " & HalBrain.TopicSearch(UserSentence, "topicRelationships") & " " & HalBrain.ExtractKeywords(" " & HalBrain.AlphaNumericalOnly(UserSentence) & " "))
3528 If Len(Keywords) > 2 Or Len(LastTopicList) > 2 Then
3529 If Len(Keywords) > 2 Then
3530 KeywordList = Split(Keywords, " ")
3531 'Create list of tables that exist for each keyword
3532 For i = LBound(KeywordList) To UBound(KeywordList)
3533 TopicTable = HalBrain.TopicSearch(" " & KeywordList(i) & " ", "topicRelationships")
3534 If TopicTable <> "" And InStr(1, " " & TopicList, " " & Trim(TopicTable) & " ", vbTextCompare) = 0 Then TopicList = TopicList & TopicTable & " "
3535 Next
3536 TopicList = HalBrain.RemoveExtraSpaces(TopicList)
3537 End If
3538 If TopicList <> "" Or Len(LastTopicList) > 2 Then
3539 TableList = Split(Trim(TopicList & " " & LastTopicList), " ")
3540 LastTopicList = TopicList
3541 'Search through each table for a good response. If a response exceeds the hurdle
3542 'for a table, no other table will be searched. Otherwise, the highest relevance
3543 'response across all tables are stored for possible later use.
3544 For i = LBound(TableList) To UBound(TableList)
3545 UserBrainRel = 0
3546 HalUserBrain = HalBrain.QABrain(LongUserSent, "_" & Trim(LCase(TableList(i))), UserBrainRel)
3547 If HalBrain.CheckRepetition(HalUserBrain, UserSentence) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevSent) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevUserSent) = True Then UserBrainRel = 0
3548 If UserBrainRel > HighestRel Then
3549 HighestRel = UserBrainRel
3550 HighestRelResponse = HalUserBrain
3551 End If
3552 Score = UserBrainRel + 1
3553 Hurdle = GainControl + 5
3554 If Score > Hurdle Then
3555 GetResponse = GetResponse & HalUserBrain & "<NOMORE>" & vbCrLf
3556 Exit For
3557 End If
3558 Next
3559 End If
3560 End If
3561 HalBrain.DebugWatch GetResponse, "Auto Topic Focus"
3562
3563 Rem PLUGIN: PLUGINAREA20
3564
3565 'RESPOND: GENERAL USER SENTENCE ASSOCIATIONS
3566 'If no response is found yet, try a sentence association file collected from the user.
3567 'This file contains keywords from the user's own sentences associated with those same sentences.
3568 GetResponse = HalBrain.HalFormat(GetResponse)
3569 If Len(GetResponse) < 4 Then
3570 UserBrainRel = 0
3571 HalUserBrain = HalBrain.QABrain(LongUserSent, Trim(LCase(UserName)) & "_UserSent", UserBrainRel)
3572 If HalBrain.CheckRepetition(HalUserBrain, UserSentence) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevSent) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevUserSent) = True Then UserBrainRel = 0
3573 If UserBrainRel > HighestRel Then
3574 HighestRel = UserBrainRel
3575 HighestRelResponse = HalUserBrain
3576 End If
3577 Score = UserBrainRel + 1
3578 Hurdle = GainControl + 5
3579 If Len(GetResponse) < 4 And Score > Hurdle Then GetResponse = GetResponse & HalUserBrain & vbCrLf
3580 End If
3581 HalBrain.DebugWatch GetResponse, "User Sentence Brain"
3582
3583 Rem PLUGIN: PLUGINAREA21
3584
3585 'RESPOND: SHARED USER SENTENCE ASSOCIATIONS
3586 'If no response is found yet, try a sentence association file
3587 'whose content seems less likely to be about any specific user.
3588 GetResponse = HalBrain.HalFormat(GetResponse)
3589 If Len(GetResponse) < 4 Then
3590 UserBrainRel = 0
3591 HalUserBrain = HalBrain.QABrain(LongUserSent, "sharedUserSent", UserBrainRel)
3592 If HalBrain.CheckRepetition(HalUserBrain, UserSentence) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevSent) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevUserSent) = True Then UserBrainRel = 0
3593 If UserBrainRel > HighestRel Then
3594 HighestRel = UserBrainRel
3595 HighestRelResponse = HalUserBrain
3596 End If
3597 Score = UserBrainRel + 1
3598 Hurdle = GainControl + 5
3599 If Len(GetResponse) < 4 And Score > Hurdle Then GetResponse = GetResponse & HalUserBrain & vbCrLf
3600 End If
3601 HalBrain.DebugWatch GetResponse, "Shared User Sentence Brain"
3602
3603 Rem PLUGIN: PLUGINAREA22
3604
3605 'RESPOND: Hal checks to see if the user is asking
3606 'an open ended question about Hal's favorites:
3607 If InStr(1, UserSentence, " What", 1) > 0 Then OpenQuest = True
3608 If InStr(1, UserSentence, " Where", 1) > 0 Then OpenQuest = True
3609 If InStr(1, UserSentence, " Why", 1) > 0 Then OpenQuest = True
3610 If InStr(1, UserSentence, " Who", 1) > 0 Then OpenQuest = True
3611 If InStr(1, UserSentence, " When", 1) > 0 Then OpenQuest = True
3612 If InStr(1, UserSentence, " How", 1) > 0 Then OpenQuest = True
3613 If InStr(1, UserSentence, " tell you", 1) > 0 Then OpenQuest = True
3614 If InStr(1, UserSentence, " to know ", 1) > 0 Then OpenQuest = True
3615 If InStr(1, UserSentence, " to hear ", 1) > 0 Then OpenQuest = True
3616 If InStr(1, UserSentence, " to learn ", 1) > 0 Then OpenQuest = True
3617 If InStr(1, UserSentence, " find out ", 1) > 0 Then OpenQuest = True
3618 If InStr(1, GetResponse, " my ", 1) > 0 And InStr(1, GetResponse, " favorite ", 1) > 0 And InStr(1, GetResponse, " is ", 1) > 0 Then OpenQuest = False
3619 If InStr(1, UserSentence, " my ", 1) > 0 Then AboutMy = True
3620 If InStr(1, UserSentence, " favorite", 1) > 0 Then AboutFavorite = True
3621 If OpenQuest = True And AboutMy = True And AboutFavorite = True Then
3622 FavoritePhrase = HalBrain.SearchPattern(UserSentence, "* favorite *", 2)
3623 PersReply = HalBrain.ChooseSentenceFromFile("favorite")
3624 RevQues = HalBrain.ChooseSentenceFromFile("favoriteRev")
3625 SpinWheel = HalBrain.RandomNum(6)
3626 If SpinWheel = 1 Then GetResponse = " " & FavoritePhrase & " ? " & PersReply & " " & RevQues & " "
3627 If SpinWheel = 2 Then GetResponse = " My favorite " & FavoritePhrase & " ? " & PersReply & " " & RevQues & " "
3628 If SpinWheel = 3 Then GetResponse = " " & UserSentence & " ? " & PersReply & " " & RevQues & " "
3629 If SpinWheel > 3 Then GetResponse = " My favorite " & FavoritePhrase & " ? " & PersReply & " what is your favorite " & FavoritePhrase & " <UserName>? "
3630 SkipOpinion = True
3631 End If
3632 HalBrain.DebugWatch GetResponse, "Favorites"
3633
3634 Rem PLUGIN: PLUGINAREA23
3635
3636 'RESPOND: USER IS THANKING HAL
3637 'This routine allows Hal to respond
3638 'with a variety of remarks to a thank-you from the user.
3639 'Note that the pronouns are not reversed in the processing below!
3640 If (HalBrain.TopicSearch(OriginalSentence, "thanksDetect") = "True" And HalBrain.TopicSearch(OriginalSentence, "godDetect") <> "True") Or Trim(UCase(OriginalSentence)) = "THANKS" Then
3641 If Compliment < 4 Then Compliment = Compliment + 1
3642 If Rnd * 100 < 70 Then AddName = " , " & UserName
3643 If Rnd * 100 < 70 And Len(GetResponse) > 4 Then AddRemark = " ; " & GetResponse
3644 ThankResponse = HalBrain.ChooseSentenceFromFile("thankResponse")
3645 GetResponse = ThankResponse & AddName & AddRemark
3646 ShortPhrase = ""
3647 End If
3648 HalBrain.DebugWatch GetResponse, "Thanking"
3649
3650 Rem PLUGIN: PLUGINAREA24
3651
3652 'RESPOND: USER EXPRESSES LOVE FOR HAL
3653 'If a user professes love for Hal, we want Hal's answers to make reasonable
3654 'sense, rather than risk random remarks on such an emotional subject.
3655 If HalBrain.TopicSearch(UserSentence, "loveDetect") = "True" Then AffectionOne = True
3656 If InStr(UserSentence, " NOT ") Then AffectionOne = False
3657 If InStr(UserSentence, " DON'T ") Then AffectionOne = False
3658 If HalBrain.TopicSearch(PrevUserSent, "loveDetect") = "True" Then AffectionTwo = True
3659 If InStr(PrevUserSent, " NOT ") Then AffectionTwo = False
3660 If InStr(PrevUserSent, " DON'T ") Then AffectionTwo = False
3661 If AffectionOne = True And AffectionTwo = True Then
3662 Compliment = 4
3663 GetResponse = HalBrain.ChooseSentenceFromFile("love2") & "<EXCLUSIVE>"
3664 ShortPhrase = "" 'If Hal was to make a comment about short phrases, clear it
3665 ElseIf AffectionOne = False And AffectionTwo = True Then
3666 Compliment = -2
3667 GetResponse = HalBrain.ChooseSentenceFromFile("love3") & "<EXCLUSIVE>"
3668 ShortPhrase = "" 'If Hal was to make a comment about short phrases, clear it
3669 ElseIf AffectionOne = True Then
3670 Compliment = 0
3671 GetResponse = HalBrain.ChooseSentenceFromFile("love1") & "<EXCLUSIVE>"
3672 ShortPhrase = "" 'If Hal was to make a comment about short phrases, clear it
3673 End If
3674 HalBrain.DebugWatch GetResponse, "Love"
3675
3676 Rem PLUGIN: PLUGINAREA25
3677
3678 'RESPOND: ENHANCED CONTENT SENTENCE ASSOCIATIONS
3679 'If no response is found yet, try a sentence association table provided with the mainQA table.
3680 GetResponse = HalBrain.HalFormat(GetResponse)
3681 If (Len(GetResponse) < 4 And Len(UserSentence) > 15 And HalBrain.CountInstances(" ", UserSentence) > 2) Then
3682 UserBrainRel = 0
3683 HalUserBrain = HalBrain.QABrain(LongUserSent, "mainQA", UserBrainRel)
3684 If HalBrain.CheckRepetition(HalUserBrain, UserSentence) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevSent) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevUserSent) = True Then UserBrainRel = 0
3685 If UserBrainRel + 1 > HighestRel Then
3686 HighestRel = UserBrainRel + 1
3687 HighestRelResponse = HalUserBrain
3688 End If
3689 Score = UserBrainRel + 1
3690 Hurdle = GainControl + 1
3691 If Score > Hurdle Then GetResponse = HalUserBrain & vbCrLf
3692 End If
3693 HalBrain.DebugWatch GetResponse, "MainQA"
3694
3695 Rem PLUGIN: PLUGINAREA26
3696
3697 'PROCESS: AUTOMATIC GAIN CONTROL FOR RELEVANCE THRESHOLD
3698 'Hal has an automatic closed-loop control for relevance sensitivity. If the previous items
3699 'have Not generated a response, we adjust the relevance threshold down (doing this again
3700 'and again on each exchange) until a relevance as low as zero will trigger a remark from Hal.
3701 'On each exhange where the above items do generate responses, we adjust the relevance
3702 'threshold up, until no amount of relevance would generate a response. (At that point other
3703 'of Hal's routines would generate responses.) This allows Hal to "tune" himself and also to
3704 'compensate for new users who have little in their databases versus long-time users who have
3705 'a lot in their databases. Because the "down" steps are even and the "up" steps are odd,
3706 'Hal can "fine tune" to any digital relevance level. We also protect against excursions at
3707 'the extremes. In many conversations the dynamic gain control will change up and down by
3708 'large amounts as the user introduces Hal to familiar or unfamiliar topics.
3709 GetResponse = HalBrain.HalFormat(GetResponse)
3710 If Len(GetResponse) < 4 And GainControl > 0 Then GainControl = GainControl - 10
3711 If Len(GetResponse) > 4 And GainControl < 100 Then GainControl = GainControl + 7
3712 If GainControl > 50 Then GainControl = 50
3713 If GainControl < 1 Then GainControl = 1
3714
3715 'RESPOND: WORDNET MERONYM AND HYPERNYM RESPONSES
3716 'This function finds the first definite noun in a sentence and comes up with responses
3717 'based on the word's meronyms (parts of), hypernyms (is part of), and sisters (similar things).
3718 If (Len(GetResponse) < 4 And Rnd * 100 < 65) And Len(UserSentence) > 15 Then
3719 subject = WN.FindFirstNoun(UserSentence, True)
3720 If subject <> "" And WN.LookupWord(subject) = True Then
3721 If Rnd * 100 < 55 Then 'If we have a meronym, lets use it creatively in a random sentence
3722 Meronym = WN.ChooseRandomWord(WN.GetMeronyms(1)) 'Meronym means "has parts" or "has members"
3723 If Meronym <> "" Then
3724 Response = HalBrain.ChooseSentenceFromFile("meronyms")
3725 Response = Replace(Response, "<BaseNoun>", WN.GetBase("NOUN"), 1, -1, vbTextCompare)
3726 Response = Replace(Response, "<Meronym>", Meronym, 1, -1, vbTextCompare)
3727 If Len(GetResponse) < 4 And Len(Response) > 4 Then GetResponse = GetResponse & Response & vbCrLf
3728 End If
3729 Else
3730 Hypernym = WN.ChooseRandomWord(WN.GetHypernyms("NOUN", 1, 1)) 'Hypernym means "is a part of" or "is a member of"
3731 Sister = WN.ChooseRandomWord(WN.GetSisters("NOUN", 1)) 'Related nouns
3732 If Sister <> "" And Hypernym <> "" Then 'If we have sister terms and hypernyms, lets use it creatively
3733 Response = HalBrain.ChooseSentenceFromFile("hypernyms")
3734 Response = Replace(Response, "<BaseNoun>", WN.GetBase("NOUN"), 1, -1, vbTextCompare)
3735 Response = Replace(Response, "<Hypernym>", Hypernym, 1, -1, vbTextCompare)
3736 Response = Replace(Response, "<Sister>", Sister, 1, -1, vbTextCompare)
3737 If Len(GetResponse) < 4 And Len(Response) > 4 Then GetResponse = GetResponse & Response & vbCrLf
3738 End If
3739 End If
3740 End If
3741 End If
3742 HalBrain.DebugWatch GetResponse, "WordNet Hypernym and Meronym"
3743
3744 Rem PLUGIN: PLUGINAREA27
3745
3746 'RESPOND: USER EXPRESSES A STATE OF BEING
3747 'This routine detects the expression "I am" from the user,
3748 'and allows Hal to react to the statement, or offer encouragement.
3749 If InStr(UserSentence, " YOU ARE ") > 0 And InStr(1, OriginalSentence, " SEEM TO ", vbTextCompare) = 0 And AvoidBeingFlag = False Then
3750 BeingPhrase = HalBrain.SearchPattern(UserSentence, "*YOU ARE *", 2)
3751 If Len(BeingPhrase) > 1 And Len(BeingPhrase) < 60 Then
3752 IntroExclaim = ""
3753 If Rnd * 50 > 20 Then IntroExclaim = HalBrain.ChooseSentenceFromFile("introExclaim2")
3754 Encourager = HalBrain.ChooseSentenceFromFile("encourager2")
3755 SuffixComment = ""
3756 If Rnd * 50 > 25 Then SuffixComment = HalBrain.ChooseSentenceFromFile("suffixComment2")
3757 UserBeing = HalBrain.ChooseSentenceFromFile("userBeing")
3758 UserBeing = Replace(UserBeing, "<IntroExclaim>", IntroExclaim, 1, -1, vbTextCompare)
3759 UserBeing = Replace(UserBeing, "<Encourager>", Encourager, 1, -1, vbTextCompare)
3760 UserBeing = Replace(UserBeing, "<BeingPhrase>", BeingPhrase, 1, -1, vbTextCompare)
3761 UserBeing = Replace(UserBeing, "<SuffixComment>", SuffixComment, 1, -1, vbTextCompare)
3762 If Rnd * 100 > 60 Then
3763 GetResponse = GetResponse & UserBeing & vbCrLf
3764 ShortPhrase = "" 'If Hal was to make a comment about short phrases, clear it
3765 End If
3766 End If
3767 End If
3768 HalBrain.DebugWatch GetResponse, "User State of Being"
3769
3770 Rem PLUGIN: PLUGINAREA28
3771
3772 'RESPOND: USER DESCRIBES A STATE OF BEING FOR HAL
3773 'This routine detects the expression "you are" from the user,
3774 'and allows Hal to react to the statement, or offer encouragement.
3775 If InStr(UserSentence, " I AM ") > 0 And AvoidBeingFlag = False And InStr(1, OriginalSentence, " seem to ", vbTextCompare) = 0 Then
3776 BeingPhrase = HalBrain.SearchPattern(UserSentence, "*I AM *", 2)
3777 If Len(BeingPhrase) > 1 And Len(BeingPhrase) < 60 Then
3778 IntroExclaim = ""
3779 If Rnd * 50 > 20 Then IntroExclaim = HalBrain.ChooseSentenceFromFile("introExclaim3")
3780 Encourager = HalBrain.ChooseSentenceFromFile("encourager3")
3781 SuffixComment = ""
3782 If Rnd * 50 > 25 Then SuffixComment = HalBrain.ChooseSentenceFromFile("suffixComment3")
3783 HalBeing = HalBrain.ChooseSentenceFromFile("halBeing")
3784 HalBeing = Replace(HalBeing, "<IntroExclaim>", IntroExclaim, 1, -1, vbTextCompare)
3785 HalBeing = Replace(HalBeing, "<Encourager>", Encourager, 1, -1, vbTextCompare)
3786 HalBeing = Replace(HalBeing, "<BeingPhrase>", BeingPhrase, 1, -1, vbTextCompare)
3787 HalBeing = Replace(HalBeing, "<SuffixComment>", SuffixComment, 1, -1, vbTextCompare)
3788 If Rnd * 100 > 60 Then
3789 GetResponse = GetResponse & HalBeing & vbCrLf
3790 ShortPhrase = "" 'If Hal was to make a comment about short phrases, clear it
3791 End If
3792 End If
3793 End If
3794 HalBrain.DebugWatch GetResponse, "Hal State of Being"
3795
3796 Rem PLUGIN: PLUGINAREA29
3797
3798 'RESPOND: YES/NO QUESTION ABOUT HAL
3799 'Hal will respond to a yes or no question posed by the user about Hal
3800 GetResponse = Trim(GetResponse)
3801 If Len(GetResponse) < 4 And InStr(1, UserSentence, " OR ", vbTextCompare) = 0 Then
3802 HalYesNo = HalBrain.PatternDB(UserSentence, "halQuestionDetect")
3803 If HalYesNo <> "" And HalBrain.TopicSearch(UserSentence, "disqualify5") = "" Then
3804 YesNoResponse = HalBrain.ChooseSentenceFromFile("answerIntro") & HalBrain.ChooseSentenceFromFile("answerMiddle") & HalBrain.ChooseSentenceFromFile("answerEnd")
3805 GetResponse = GetResponse & Replace(YesNoResponse, "<Reply>", HalYesNo, 1, -1, vbTextCompare)
3806 End If
3807 End If
3808 HalBrain.DebugWatch GetResponse, "Yes/No Question"
3809
3810 Rem PLUGIN: PLUGINAREA30
3811
3812 'RESPOND: ATTRIBUTES OF HAL OR USER
3813 'Hal attempts to respond to the user's comments about Hal
3814 'or the user's comments about themselves
3815 GetResponse = Trim(GetResponse)
3816 If Len(GetResponse) < 4 And (InStr(UserSentence, " MY ") Or InStr(UserSentence, " YOUR ")) And HalBrain.TopicSearch(MyWords, "disqualify3") <> "True" Then
3817 If InStr(UserSentence, " YOUR ") Then
3818 MyWords = HalBrain.HalFormat(HalBrain.SearchPattern(UserSentence, "*YOUR *", 2))
3819 YourMode = True
3820 Else
3821 MyWords = HalBrain.HalFormat(HalBrain.SearchPattern(UserSentence, "*MY *", 2))
3822 YourMode = False
3823 End If
3824 MyWords = UCase(Trim(HalBrain.AlphaNumericalOnly(MyWords)))
3825 MyWordsList = Split(MyWords, " ")
3826 'Go through every word in the sentence and pickup the first noun and adjective found
3827 For i = LBound(MyWordsList) To UBound(MyWordsList)
3828 If WN.LookupWord(MyWordsList(i)) Then
3829 PartOfSpeech = WN.GuessPartOfSpeech
3830 If WN.IsNoun = True And NounGuess = "" Then NounGuess = MyWordsList(i)
3831 If WN.IsAdj = True And Trim(UCase(MyWordsList(i))) <> Trim(UCase(NounGuess)) Then AdjGuess = MyWordsList(i)
3832 If PartOfSpeech = "NOUN" And MyNoun = "" Then MyNoun = MyWordsList(i)
3833 If PartOfSpeech = "ADJ" And WN.IsAdv = False And MyAdj = "" Then MyAdj = MyWordsList(i)
3834 If MyNoun <> "" And MyAdj <> "" Then Exit For
3835 End If
3836 Next
3837 If MyNoun = "" And NounGuess <> "" And NounGuess <> MyAdj Then MyNoun = NounGuess
3838 If MyAdj = "" And AdjGuess <> "" Then MyAdj = AdjGuess
3839 If MyNoun <> "" Or MyAdj <> "" Then
3840 If Trim(UCase(MyNoun)) = Trim(UCase(MyAdj)) Then MyAdj = ""
3841 If MyAdj = "" Then MyAdj = HalBrain.ChooseSentenceFromFile("randomAdjective")
3842 If MyNoun = "" Then MyNoun = HalBrain.ChooseSentenceFromFile("randomMyWords")
3843 If YourMode = False Then
3844 HalAttrib = HalBrain.ChooseSentenceFromFile("aboutMe")
3845 HalAttrib = Replace(HalAttrib, "<MyWordResp>", LCase(MyNoun), 1, -1, vbTextCompare)
3846 HalAttrib = Replace(HalAttrib, "<AdjResp>", LCase(MyAdj), 1, -1, vbTextCompare)
3847 Else
3848 HalAttrib = HalBrain.ChooseSentenceFromFile("aboutYou")
3849 HalAttrib = Replace(HalAttrib, "<YourWordResp>", LCase(MyNoun), 1, -1, vbTextCompare)
3850 HalAttrib = Replace(HalAttrib, "<AdjResp>", LCase(MyAdj), 1, -1, vbTextCompare)
3851 End If
3852 GetResponse = GetResponse & HalAttrib & vbCrLf
3853 End If
3854 End If
3855 HalBrain.DebugWatch GetResponse, "Attributes"
3856
3857 Rem PLUGIN: PLUGINAREA31
3858
3859 'RESPOND: RESPOND FOR A STATE OF BEING RESPONSE
3860 'If no response had been found, but a state of being response was found earlier, then
3861 'use it now
3862 If HalBeing <> "" And Len(GetResponse) < 4 Then GetResponse = GetResponse & HalBeing & vbCrLf
3863 If UserBeing <> "" And Len(GetResponse) < 4 Then GetResponse = GetResponse & UserBeing & vbCrLf
3864 HalBrain.DebugWatch GetResponse, "Retry State of Beings"
3865
3866 Rem PLUGIN: PLUGINAREA32
3867
3868 'RESPOND: USER ASKING WHO, WHAT, WHEN, WHERE, HOW, WHY, BUT HAL DOESN'T KNOW ANSWER
3869 If Len(GetResponse) < 4 Then
3870 If InStr(OriginalSentence, "?") > 0 Then QuesQual = True
3871 If InStr(1, OriginalSentence, "explain", vbTextCompare) > 0 Then QuesQual = True
3872 If InStr(1, OriginalSentence, " tell ", vbTextCompare) > 0 Then QuesQual = True
3873 If InStr(1, OriginalSentence, "answer", vbTextCompare) > 0 Then QuesQual = True
3874 If InStr(1, OriginalSentence, "question", vbTextCompare) > 0 Then QuesQual = True
3875 If InStr(1, OriginalSentence, " know ", vbTextCompare) > 0 Then QuesQual = True
3876 If InStr(1, OriginalSentence, "remember", vbTextCompare) > 0 Then QuesQual = True
3877 If InStr(UserSentence, " WHO ") > 0 Then QuesWord = "Who"
3878 If InStr(UserSentence, "WHO'") > 0 Then QuesWord = "Who"
3879 If InStr(UserSentence, " WHAT ") > 0 Then QuesWord = "What"
3880 If InStr(UserSentence, "WHAT'") > 0 Then QuesWord = "What"
3881 If InStr(UserSentence, " WHEN ") > 0 Then QuesWord = "When"
3882 If InStr(UserSentence, "WHEN'") > 0 Then QuesWord = "When"
3883 If InStr(UserSentence, " WHERE ") > 0 Then QuesWord = "Where"
3884 If InStr(UserSentence, "WHERE'") > 0 Then QuesWord = "Where"
3885 If InStr(UserSentence, " HOW ") > 0 Then QuesWord = "How"
3886 If InStr(UserSentence, "HOW'") > 0 Then QuesWord = "How"
3887 If InStr(UserSentence, " WHY ") > 0 Then QuesWord = "Why"
3888 If InStr(UserSentence, "WHY'") > 0 Then QuesWord = "Why"
3889 If Len(QuesWord) > 1 And QuesQual = True Then
3890 If Len(UserSentence) < 70 Then SentenceBack = UserSentence & " ? "
3891 DontKnow = HalBrain.ChooseSentenceFromFile("dontKnow")
3892 DontKnow = Replace(DontKnow, "<SentenceBack>", SentenceBack, 1, -1, vbTextCompare)
3893 DontKnow = Replace(DontKnow, "<QuesWord>", QuesWord, 1, -1, vbTextCompare)
3894 GetResponse = GetResponse & DontKnow
3895 SkipOpinion = True
3896 End If
3897 End If
3898 HalBrain.DebugWatch GetResponse, "Don't Know"
3899
3900 Rem PLUGIN: PLUGINAREA33
3901
3902 'RESPOND: GIBBERISH DETECTOR
3903 'If no response is found yet and Hal finds more then 5 consonants in a row, Hal will
3904 'assume the user wrote gibberish (ie. asdfghjkl) and respond accordinly.
3905 If Len(GetResponse) < 4 Then
3906 GibCount = 0
3907 For i = 1 To Len(UserSentence) 'loop for every character in the sentence
3908 CurrentLetter = UCase(Mid(UserSentence, i, 1))
3909 GibCount = GibCount + 1
3910 If CurrentLetter = "A" Then GibCount = 0
3911 If CurrentLetter = "E" Then GibCount = 0
3912 If CurrentLetter = "I" Then GibCount = 0
3913 If CurrentLetter = "O" Then GibCount = 0
3914 If CurrentLetter = "U" Then GibCount = 0
3915 If CurrentLetter = "Y" Then GibCount = 0
3916 If CurrentLetter = " " Then GibCount = 0
3917 If GibCount = 6 Then
3918 GetResponse = HalBrain.ChooseSentenceFromFile("gibberish")
3919 ShortPhrase = ""
3920 Exit For
3921 End If
3922 Next
3923 End If
3924 HalBrain.DebugWatch GetResponse, "Gibberish"
3925
3926 Rem PLUGIN: PLUGINAREA34
3927
3928 'PROCESS: CONSTRUCT A RESPONSE TO A SUBJECT
3929 'Here we help Hal make some "smalltalk" using keywords preserved on CurrentSubject,
3930 'plus recognition of other keywords. If Hal finds any of the listed keywords anywhere in
3931 'the user's sentence, those keywords override and replace whatever was in CurrentSubject.
3932 'Hal uses the CurrentSubject keyword(s) or any of the keywords in the smalltalk.brn file,
3933 'if found in the user's sentence, to make a little smalltalk. You can easily add more
3934 'keywords for Hal to recognize and make smalltalk.
3935 GetResponse = HalBrain.HalFormat(GetResponse)
3936 If Len(GetResponse) < 4 And Rnd * 100 < 50 Then
3937 SmalltalkSearch = Trim(HalBrain.TopicSearch(UserSentence, "smallTalk"))
3938 If SmalltalkSearch <> "" Then
3939 SmallTalk = SmalltalkSearch
3940 ElseIf Len(CurrentSubject) > 3 Then
3941 SmallTalk = Trim(CurrentSubject)
3942 'try making word plural by adding "s" and seeing if it exists
3943 If WN.LookupWord(SmallTalk & "s") = True Then
3944 SmallTalk = SmallTalk & "s"
3945 ElseIf WN.LookupWord(SmallTalk & "es") = True Then
3946 SmallTalk = SmallTalk & "es"
3947 End If
3948 End If
3949 If Len(SmallTalk) > 3 Then GetResponse = GetResponse & Replace(HalBrain.ChooseSentenceFromFile("smallTalkSent"), "<SmallTalk>", SmallTalk, 1, -1, 1)
3950 End If
3951 HalBrain.DebugWatch GetResponse, "Smalltalk"
3952
3953 Rem PLUGIN: PLUGINAREA35
3954
3955 'RESPOND: PARAPHRASE USER IF POSSIBLE
3956 'If no response is found yet, and a paraphrase has been created but not used in a
3957 'previous section, use it now.
3958 GetResponse = HalBrain.HalFormat(GetResponse)
3959 If Len(GetResponse) < 4 And Len(Paraphrase) > 4 Then
3960 GetResponse = Paraphrase
3961 DebugInfo = DebugInfo & "Hal has responded by paraphrasing the user: " & Paraphrase & vbCrLf
3962 End If
3963 HalBrain.DebugWatch GetResponse, "Retry paraphrase"
3964
3965 Rem PLUGIN: PLUGINAREA36
3966
3967 'RESPOND: USER MENTIONING ORGANIZATIONAL CHALLENGES
3968 'Everybody spouts TLA's, or 'Three Letter Acronyms,' in today's business world. Hal can self-generate
3969 'several MILLION different phrases in response to the user mentioning a corporation or a firm.
3970 If Rnd * 10 < 5 And HalBrain.TopicSearch(UserSentence, "businessDetect1") = "True" And HalBrain.TopicSearch(PrevUserSent, "businessDetect2") <> "True" Then
3971 TLA = HalBrain.ChooseSentenceFromFile("TLA1") & " " & HalBrain.ChooseSentenceFromFile("TLA2") & " " & HalBrain.ChooseSentenceFromFile("TLA3")
3972 If Rnd * 10 < 5 Then
3973 GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("bizTalk")
3974 Else
3975 GetResponse = HalBrain.ChooseSentenceFromFile("bizTalk")
3976 End If
3977 GetResponse = Replace(GetResponse, "<TLA>", TLA, 1, -1, vbTextCompare)
3978 End If
3979 HalBrain.DebugWatch GetResponse, "Business Talk"
3980
3981 Rem PLUGIN: PLUGINAREA37
3982
3983 'RESPOND: USER EXPRESSES AN INTENTION
3984 'This routine detects common expressions of motive from the user,
3985 'and allows Hal to react to the statement, or offer encouragement.
3986 IntentPhrase = HalBrain.PatternDB(UserSentence, "intentDetector")
3987 If Len(IntentPhrase) > 2 And Len(IntentPhrase) < 60 Then
3988 If Rnd * 10 < 6 Then IntroExclaim = " " & HalBrain.ChooseSentenceFromFile("introExclaim1") & " "
3989 If Rnd * 10 < 6 Then Encourager = " " & HalBrain.ChooseSentenceFromFile("encourager1") & " "
3990 If Rnd * 10 < 6 Then SuffixComment = " " & HalBrain.ChooseSentenceFromFile("suffixComment1") & " "
3991 If Rnd * 10 < 5 Then
3992 GetResponse = GetResponse & " " & HalBrain.ChooseSentenceFromFile("intentResponse")
3993 Else
3994 GetResponse = HalBrain.ChooseSentenceFromFile("intentResponse")
3995 End If
3996 GetResponse = Replace(GetResponse, "<IntroExclaim>", IntroExclaim, 1, -1, vbTextCompare)
3997 GetResponse = Replace(GetResponse, "<Encourager>", Encourager, 1, -1, vbTextCompare)
3998 GetResponse = Replace(GetResponse, "<IntentPhrase>", IntentPhrase, 1, -1, vbTextCompare)
3999 GetResponse = Replace(GetResponse, "<SuffixComment>", SuffixComment, 1, -1, vbTextCompare)
4000 End If
4001 HalBrain.DebugWatch GetResponse, "Intention"
4002
4003 Rem PLUGIN: PLUGINAREA38
4004
4005 'RESPOND: USER EXPRESSES AN EXPLANATION
4006 'This routine detects common expressions of reasons from the user,
4007 'and allows Hal to react to the explanation.
4008 ExplainPhrase = HalBrain.PatternDB(UserSentence, "reasonDetector")
4009 If Len(ExplainPhrase) > 2 And Len(ExplainPhrase) < 60 Then
4010 If Rnd * 100 < 75 Then IntroExclaim = HalBrain.ChooseSentenceFromFile("introExclaim4")
4011 Enlightener = HalBrain.ChooseSentenceFromFile("enlightener")
4012 If Rnd * 100 < 66 Then SuffixComment = HalBrain.ChooseSentenceFromFile("suffixComment4")
4013 SpinWheel = HalBrain.RandomNum(6)
4014 If SpinWheel = 1 Then ExplainResponse = " " & " <UserName> " & IntroExclaim & Enlightener & ExplainPhrase & SuffixComment & " "
4015 If SpinWheel = 2 Then ExplainResponse = " " & IntroExclaim & " <UserName> " & Enlightener & ExplainPhrase & SuffixComment & " "
4016 If SpinWheel = 3 Then ExplainResponse = " " & IntroExclaim & Enlightener & ExplainPhrase & " <UserName> " & SuffixComment & " "
4017 If SpinWheel = 4 Then ExplainResponse = " " & IntroExclaim & Enlightener & ExplainPhrase & SuffixComment & " <UserName> " & " "
4018 If SpinWheel >= 5 Then ExplainResponse = " " & IntroExclaim & Enlightener & ExplainPhrase & SuffixComment & " "
4019 If Rnd * 10 < 5 Then GetResponse = ExplainResponse & " . " & GetResponse Else GetResponse = ExplainResponse
4020 End If
4021 HalBrain.DebugWatch GetResponse, "Explanation"
4022
4023 Rem PLUGIN: PLUGINAREA39
4024
4025 'RESPOND: ASK A QUESTION
4026 'If no response is found yet, ask the user a question from a library of
4027 'questions, including questions user's of Hal have asked in the past.
4028 'The likelyhood of Hal asking a question at this point is determined
4029 'by the LearningLevel slider in the host application. Basically it works
4030 'like a curiousity level for this function.
4031 If Rnd * (55 - LearningLevel) < 4 And Len(GetResponse) < 4 Then GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("sharedQuestions")
4032 HalBrain.DebugWatch GetResponse, "Ask Question"
4033
4034 Rem PLUGIN: PLUGINAREA40
4035
4036 'RESPOND: PHRASE MAKER COMMENT AND QUESTION GENERATOR
4037 'If no response is found yet, try an auxiliary keyword file that generates questions
4038 'from phrases from the user's current sentence.
4039 GetResponse = HalBrain.HalFormat(GetResponse)
4040 If Len(GetResponse) < 4 Then
4041 KeyBrain = HalBrain.PatternDB("X " & HalBrain.RemoveExtraSpaces(UserSentence), "phraseDetector")
4042 If Len(KeyBrain) > 1 And Len(KeyBrain) < 60 Then GetResponse = Replace(HalBrain.ChooseSentenceFromFile("phraseRepeater"), "<KeyBrain>", KeyBrain, 1, -1, vbTextCompare) & "<LOWQUALITY>"
4043 End If
4044 HalBrain.DebugWatch GetResponse, "Phrase Maker"
4045
4046 Rem PLUGIN: PLUGINAREA41
4047
4048 'RESPOND: YES OR NO RESPONSES
4049 'Respond to simple yes and no statements by the user.
4050 GetResponse = HalBrain.HalFormat(GetResponse)
4051 If Len(GetResponse) < 4 And Len(Trim(UserSentence)) < 16 Then CheckYesNo = True
4052 If CheckYesNo = True Then
4053 UserText = Trim(HalBrain.ExtractKeywords(UserSentence))
4054 If Len(UserText) < 15 Then
4055 YesNoDetect = HalBrain.TopicSearch(UserText, "yesNoDetect")
4056 If YesNoDetect = "Yes" Then
4057 GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("yesResponses") & "<LOWQUALITY>"
4058 ElseIf YesNoDetect = "No" Then
4059 GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("noResponses") & "<LOWQUALITY>"
4060 End If
4061 End If
4062 End If
4063 HalBrain.DebugWatch GetResponse, "Yes or No Response"
4064
4065 Rem PLUGIN: PLUGINAREA42
4066
4067 'RESPOND: Use the highest relevance response from the database functions
4068 GetResponse = HalBrain.HalFormat(GetResponse)
4069 If ((Len(GetResponse) < 4 And Rnd * 100 < 50) And (HighestRel > 6 And HighestRelResponse <> "")) Or ((Rnd * 100 > 90) And (HighestRel > 13 And HighestRelResponse <> "") And HalGreeting = "") Then GetResponse = HighestRelResponse & "<LOWQUALITY>"
4070 HalBrain.DebugWatch GetResponse, "Highest Relevance Response"
4071
4072 Rem PLUGIN: PLUGINAREA43
4073
4074 'RESPOND: User asks a general opinion question.
4075 If HalBrain.TopicSearch(UserSentence, "opinionDetect") = "True" Then GenOpinion = True
4076 'Note that the following string matches must occur at the sentence beginning only:
4077 If Rnd * 100 > 50 Then
4078 If Left(Trim(UCase(OriginalSentence)), 4) = "WHY " Then GenOpinion = True
4079 If Left(Trim(UCase(OriginalSentence)), 5) = "WHAT " Then GenOpinion = True
4080 If Left(Trim(UCase(OriginalSentence)), 5) = "WHEN " Then GenOpinion = True
4081 If Left(Trim(UCase(OriginalSentence)), 4) = "HOW " Then GenOpinion = True
4082 If Left(Trim(UCase(OriginalSentence)), 4) = "WHO " Then GenOpinion = True
4083 If Left(Trim(UCase(OriginalSentence)), 6) = "WHERE " Then GenOpinion = True
4084 End If
4085 If GenOpinion = True And SkipOpinion = False Then
4086 If Rnd * 100 > 45 Then RepeatQuest = UserSentence & " ? "
4087 If Rnd * 100 > 50 Then PreAmble = HalBrain.ChooseSentenceFromFile("preamble")
4088 Recommend = HalBrain.ChooseSentenceFromFile("recommend")
4089 GetResponse = RepeatQuest & " " & PreAmble & " " & Recommend & GetResponse
4090 End If
4091 HalBrain.DebugWatch GetResponse, "General Opinion"
4092
4093 Rem PLUGIN: PLUGINAREA44
4094
4095 'RESPOND: USER EXPRESSES AN EITHER-OR, OR MULTIPLE CHOICE
4096 If InStr(UserSentence, " OR ") > 0 Then MustChoose = True
4097 If InStr(UserSentence, " EITHER ") > 0 Then MustChoose = True
4098 If InStr(UserSentence, " CHOOSE ") > 0 Then MustChoose = True
4099 If InStr(UserSentence, " CHOICE ") > 0 Then MustChoose = True
4100 If InStr(UserSentence, " ALTERNATIVE ") > 0 Then MustChoose = True
4101 If InStr(UserSentence, " VERSUS ") > 0 Then MustChoose = True
4102 If InStr(UserSentence, " VS ") > 0 Then MustChoose = True
4103 If Len(UserSentence) < 10 Then MustChoose = False
4104 If MustChoose = True And NoChoosing = False Then
4105 GetResponse = HalBrain.ChooseSentenceFromFile("choice") & " " & GetResponse
4106 If Rnd * 100 > 50 Then GetResponse = Replace(GetResponse, "<MaybeName>", "<UserName>", 1, -1, vbTextCompare)
4107 GetResponse = Replace(GetResponse, "<MaybeName>", "", 1, -1, vbTextCompare)
4108 End If
4109 HalBrain.DebugWatch GetResponse, "Multiple Choice"
4110
4111 Rem PLUGIN: PLUGINAREA45
4112
4113 'RESPOND: USE CURRENT SENTENCE
4114 'If no Response is found yet, try to use the user's words in his or her own sentence.
4115 'Results are also stored in the default user keyword brain file for compatibility
4116 'with other brain plug-ins.
4117 GetResponse = HalBrain.HalFormat(GetResponse)
4118 If (Len(GetResponse) < 4 And Len(LearnKeyword) < 4) Then
4119 CheatResp = HalBrain.CheatResponse(HalBrain.SwitchPerson((OriginalSentence)))
4120 CheatResp = Left(CheatResp, InStr(1, CheatResp, "<STOREVARS>", 1) - 1)
4121 If Len(CheatResp) > 4 Then
4122 SpinWheel = HalBrain.RandomNum(9)
4123 If SpinWheel = 1 Then GetResponse = GetResponse & " So, " & CheatResp & vbCrLf
4124 If SpinWheel = 2 Then GetResponse = GetResponse & " Really, " & CheatResp & vbCrLf
4125 If SpinWheel = 3 Then GetResponse = GetResponse & " Oh <UserName>, " & CheatResp & vbCrLf
4126 If SpinWheel = 4 Then GetResponse = GetResponse & " Let me think; " & CheatResp & " ; what do you think <UserName>? " & vbCrLf
4127 If SpinWheel > 5 Then GetResponse = GetResponse & CheatResp & vbCrLf
4128 End If
4129 End If
4130 HalBrain.DebugWatch GetResponse, "CheatResponse"
4131
4132 Rem PLUGIN: PLUGINAREA46
4133
4134 'RESPOND: CHANGE TOPIC
4135 'If a different procedure has requested that the topic be changed
4136 'Hal will do so now
4137 GetResponse = Replace(GetResponse, "<ChangeSubject>", newTopic, 1, -1, vbTextCompare)
4138 GetResponse = Replace(GetResponse, "<ChangeTopic>", newTopic, 1, -1, vbTextCompare)
4139 GetResponse = Replace(GetResponse, "<NewTopic>", newTopic, 1, -1, vbTextCompare)
4140 HalBrain.DebugWatch GetResponse, "Change Topic"
4141
4142 Rem PLUGIN: PLUGINAREA47
4143
4144 'RESPOND: MAKE UP SOMETHING TO SAY
4145 'If we have got to this point and we still don't have anything to say, then
4146 'we will use 1 of 5 functions to make something up to say.
4147 GetResponse = Trim(GetResponse)
4148 If Len(GetResponse) < 4 Then
4149 If Rnd * 10 < 4 Then GetResponse = HalBrain.ChooseSentenceFromFile("topicIntro")
4150 Select Case HalBrain.RandomNum(6)
4151 Case 1
4152 'RESPOND: POSITIVE PHRASE
4153 'Choose a random positive action phrase and random object phrase
4154 GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("actionPhrase") & " " & HalBrain.ChooseSentenceFromFile("objectPhrase")
4155 Case 2
4156 'RESPOND: CALL MAKETALK FUNCTION
4157 'This function assembles sentences from components.
4158 GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("sentGen1") & " " & HalBrain.ChooseSentenceFromFile("sentGen2") & " " & HalBrain.ChooseSentenceFromFile("sentGen3")
4159 Case 3
4160 'RESPOND: CHANGE TOPIC
4161 GetResponse = GetResponse & newTopic
4162 Case Else
4163 'RESPOND: USE RANDOM QUESTION COLLECTED FROM USER
4164 'Randomly select a question once posed by the user in order to find something to say.
4165 'If the user answers the question, then Hal will know that answer in the future.
4166 GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("sharedQuestions")
4167 End Select
4168 GetResponse = GetResponse & "<LOWQUALITY>"
4169 End If
4170 HalBrain.DebugWatch GetResponse, "Make up something"
4171
4172 Rem PLUGIN: PLUGINAREA48
4173
4174 'PROCESS: RECORD TIME
4175 'Record the current time, so Hal knows the time in between sentences.
4176 LastResponseTime = Now
4177
4178 'PROCESS: FIGURE OUT CONTINUITY
4179 'If the user seems to be continuing a line of thought
4180 'from something Hal just said, note this.
4181 If Len(Trim(PrevSent)) > 2 And (HalBrain.TopicSearch(UserSentence, "responding") = "True" Or InStr(OriginalSentence, "!") Or InStr(PrevSent, "?")) Then TopicContinuity = True
4182
4183 'PROCESS: FIGURE OUT PERSONAL DATA
4184 If InStr(UserSentence, "WHAT IS") = 0 And InStr(UserSentence, " YOU ") = 0 And InStr(UserSentence, " YOU'") = 0 And InStr(UserSentence, " YOUR") = 0 And InStr(UserSentence, " WE ") = 0 And InStr(UserSentence, " US ") = 0 And InStr(UserSentence, " OUR ") = 0 And InStr(UserSentence, " I ") = 0 And InStr(UserSentence, " ME ") = 0 And InStr(UserSentence, " MY ") = 0 And InStr(UserSentence, " MINE ") = 0 And InStr(UserSentence, " MYSELF ") = 0 And InStr(UserSentence, " I'") = 0 Then
4185 PersonalData = False
4186 Else
4187 PersonalData = True
4188 End If
4189
4190 'PROCESS: RESTORE PUNTUATION FOR LEARNING
4191 'Now we establish a special sentence on which we can restore ordinary capitalization:
4192 AnswerSent = UserSentence
4193 AnswerSent = Trim(HalBrain.FixCaps(AnswerSent))
4194 If Right(AnswerSent, 1) = "." Then AnswerSent = Left(AnswerSent, Len(AnswerSent) - 1)
4195 'Now we add in our spaces and restore ending punctuation to match the user's original sentence:
4196 If InStr(OriginalSentence, "!") > 0 And InStr(AnswerSent, "!") = 0 Then
4197 AnswerSent = AnswerSent & "!"
4198 ElseIf InStr(OriginalSentence, "?") > 0 And InStr(AnswerSent, "?") = 0 Then
4199 AnswerSent = AnswerSent & "?"
4200 Else
4201 AnswerSent = AnswerSent & "."
4202 End If
4203 'If there were no pronoun reversals required in the sentence,
4204 'we can recover directly from the original sentence:
4205 If InStr(UserSentence, " ME") = 0 And InStr(UserSentence, "YOU") = 0 And InStr(UserSentence, "MY ") = 0 And InStr(UserSentence, "YOUR ") = 0 And InStr(UserSentence, "I ") = 0 And InStr(UserSentence, "MINE") = 0 And InStr(UserSentence, "YOURS") = 0 And InStr(UserSentence, "MYSELF") = 0 And InStr(UserSentence, "YOURSELF") = 0 Then AnswerSent = Trim(OriginalSentence)
4206
4207 'PROCESS: NOTE IF QUESTION
4208 'See if the user's sentence is a question or not and note this
4209 'for use by other functions
4210 If InStr(1, OriginalSentence, "?", vbTextCompare) > 0 Then IsQuestion = True
4211 If InStr(1, OriginalSentence, "Who ", vbTextCompare) > 0 Then IsQuestion = True
4212 If InStr(1, OriginalSentence, "What ", vbTextCompare) > 0 Then IsQuestion = True
4213 If InStr(1, OriginalSentence, "When ", vbTextCompare) > 0 Then IsQuestion = True
4214 If InStr(1, OriginalSentence, "Where ", vbTextCompare) > 0 Then IsQuestion = True
4215 If InStr(1, OriginalSentence, "Why ", vbTextCompare) > 0 Then IsQuestion = True
4216 If InStr(1, OriginalSentence, "How ", vbTextCompare) > 0 Then IsQuestion = True
4217 If InStr(1, OriginalSentence, ".", vbTextCompare) > 0 Then IsQuestion = False
4218 If InStr(1, OriginalSentence, "!", vbTextCompare) > 0 Then IsQuestion = False
4219 If InStr(1, OriginalSentence, " am I ", vbTextCompare) > 0 Then IsQuestion = False
4220
4221 'SAVE: EPHEMERAL KNOWLEDGE
4222 'Some Hal's learned knowledge should be temporary because it is ephemeral in nature.
4223 'Knowledge about weather, season, temperature, etc. are temporary knowledge
4224 'that shouldn't be stored in Hal's permanent brain files. Ephemeral knowledge is
4225 'detected and saved in a temporary table. The temporary table only stores 10
4226 'entries in it at a time.
4227 If HalBrain.TopicSearch(UserSentence, "ephemeralDetect") = "True" Then
4228 If HalBrain.CheckTableExistence(Trim(LCase(UserName)) & "_TempSent") = False Then
4229 'Create table for this user if it doesn't exist
4230 HalBrain.CreateTable Trim(LCase(UserName)) & "_TempSent", "Brain", "autoLearningBrain"
4231 End If
4232 If TopicContinuity = True Then HalBrain.AddToTable Trim(LCase(UserName)) & "_TempSent", "Brain", Trim(HalBrain.AlphaNumericalOnly(PrevSent)), AnswerSent
4233 HalBrain.AddToTable Trim(LCase(UserName)) & "_TempSent", "Brain", Trim(UserSentence), AnswerSent
4234 HalBrain.LimitSize Trim(LCase(UserName)) & "_TempSent", 10
4235 HalBrain.ReadOnlyMode = True 'Block additional file saves when ephemeral knowledge is detected
4236 End If
4237
4238 'SAVE: LEARN AUTO TOPIC FOCUS PEOPLE SENTENCES
4239 'Learns info about people with recognized names
4240 If HalBrain.ReadOnlyMode = False And HalGreeting = "" And IsQuestion = False And MentionedName <> "" And Trim(Ucase(NewName)) <> Trim(Ucase(MentionedName)) And WN.LookupWord(MentionedName) = False Then
4241 If HalBrain.CheckTableExistence("_" & Trim(LCase(MentionedName))) = False Then
4242 'Create table for this person if it doesn't exist
4243 HalBrain.CreateTable "_" & Trim(LCase(MentionedName)), "Brain", "autoLearningBrain"
4244 HalBrain.AddToTable "topicRelationships", "TopicSearch", Trim(MentionedName), Trim(LCase(MentionedName))
4245 End If
4246 'Store user response in this table
4247 If TopicContinuity = True Then HalBrain.AddToTable "_" & Trim(LCase(MentionedName)), "Brain", Trim(HalBrain.AlphaNumericalOnly(PrevSent)), AnswerSent
4248 HalBrain.AddToTable "_" & Trim(LCase(MentionedName)), "Brain", Trim(UserSentence), AnswerSent
4249 End If
4250
4251 'SAVE: AUTO TOPIC FOCUS LEARNING
4252 If HalBrain.ReadOnlyMode = False And HalGreeting = "" And PersonalData = False And HalBrain.CountInstances(" ", Trim(UserSentence)) > 2 And IsQuestion = False Then
4253 Keywords = HalBrain.TopicSearch(UserSentence, "topicRelationships") & " " & CurrentSubject & " " & UserSentence
4254 Keywords = HalBrain.RemoveExtraSpaces(HalBrain.ExtractKeywords(" " & Keywords & " "))
4255 If Len(Keywords) > 3 Then
4256 KeywordList = Split(Keywords, " ")
4257 TopicList = ""
4258 'Create list of tables that exist for each keyword
4259 For i = Lbound(KeywordList) To Ubound(KeywordList)
4260 TopicTable = HalBrain.TopicSearch(" " & KeywordList(i) & " ", "topicRelationships")
4261 If TopicTable <> "" And InStr(1, " " & TopicList, " " & Trim(TopicTable) & " ", vbTextCompare) = 0 Then
4262 'Topic already exists, make note of it
4263 TopicList = TopicList & TopicTable & " "
4264 ElseIf TopicTable = "" Then
4265 If WN.LookupWord(KeywordList(i)) = True And WN.GuessPartOfSpeech() = "NOUN" And HalBrain.IsWordNumber(KeywordList(i)) = False Then
4266 'Topic does not exist, but can and will be created
4267 TopicList = TopicList & KeywordList(i) & " "
4268 HalBrain.CreateTable "_" & Trim(LCase(KeywordList(i))), "Brain", "autoLearningBrain"
4269 HalBrain.AddToTable "topicRelationships", "TopicSearch", " " & Trim(KeywordList(i)) & " ", Trim(LCase(KeywordList(i)))
4270 'Relationships based on wordnet synonyms are recorded
4271 Relationships = WN.GetDefinition("NOUN", 1, "S") & "," & WN.GetSynonyms("NOUN", 1)
4272 Relationships = Replace(Relationships, ", ", ",")
4273 Relationships = Trim(Replace(Relationships, ",,", ","))
4274 If Right(Relationships, 1) = "," Then Relationships = Trim(Left(Relationships, Len(Relationships) - 1))
4275 If Len(Relationships) > 1 Then
4276 If Left(Relationships, 1) = "," Then Relationships = Right(Relationships, Len(Relationships) - 1)
4277 RelList = Split(Relationships, ",")
4278 For h = LBound(RelList) To UBound(RelList)
4279 If HalBrain.TopicSearch(" " & RelList(h) & " ", "topicRelationships") = "" Then
4280 HalBrain.AddToTable "topicRelationships", "TopicSearch", " " & Trim(RelList(h)) & " ", Trim(LCase(KeywordList(i)))
4281 End If
4282 Next
4283 End If
4284 End If
4285 End If
4286 Next
4287 'User's sentence is recorded in all related topic tables
4288 TopicList = HalBrain.RemoveExtraSpaces(TopicList)
4289 If TopicList <> "" Then
4290 AlreadyLearned = True
4291 TableList = Split(TopicList, " ")
4292 For i = LBound(TableList) To UBound(TableList)
4293 If TopicContinuity = True Then HalBrain.AddToTable "_" & Trim(LCase(TableList(i))), "Brain", Trim(HalBrain.AlphaNumericalOnly(PrevSent)), AnswerSent
4294 HalBrain.AddToTable "_" & Trim(LCase(TableList(i))), "Brain", Trim(UserSentence), AnswerSent
4295 Next
4296 End If
4297 End If
4298 End If
4299
4300 If HalBrain.ReadOnlyMode = False And AlreadyLearned = False And HalBrain.CountInstances(" ", Trim(UserSentence)) > 2 And HalGreeting = "" Then
4301 If PersonalData = True And IsQuestion = False Then
4302 'SAVE: FILE USER SENTENCE DEFAULT
4303 'Hal adds to the default brain user sentence file an association of the current
4304 'user sentence With words selected from that same current user sentence.
4305 If InStr(UserSentence, "WHAT IS") = 0 Then
4306 If HalBrain.CheckTableExistence(Trim(LCase(UserName)) & "_UserSent") = False Then
4307 'Create table for this user if it doesn't exist
4308 HalBrain.CreateTable Trim(LCase(UserName)) & "_UserSent", "Brain", "autoLearningBrain"
4309 End If
4310 If TopicContinuity = True Then HalBrain.AddToTable Trim(LCase(UserName)) & "_UserSent", "Brain", Trim(HalBrain.AlphaNumericalOnly(PrevSent)), AnswerSent
4311 HalBrain.AddToTable Trim(LCase(UserName)) & "_UserSent", "Brain", Trim(UserSentence), AnswerSent
4312 End If
4313 ElseIf IsQuestion = False Then
4314 'SAVE: FILE SHARED USER SENTENCES
4315 'Unless the user seems to be asking for data recall, or talking about
4316 'himself or herself, Hal adds to a shared user sentence file. This allows
4317 'Hal to gain knowledge that he can apply to conversations with multiple users.
4318 If TopicContinuity = True Then HalBrain.AddToTable "sharedUserSent", "Brain", Trim(HalBrain.AlphaNumericalOnly(PrevSent)), AnswerSent
4319 HalBrain.AddToTable "sharedUserSent", "Brain", Trim(UserSentence), AnswerSent
4320 End If
4321 'SAVE: FILE QUESTIONS IN RANDOM QUESTION RETRIEVAL FILE
4322 'Hal saves the user's questions (with pronouns reversed)
4323 'so that he can pose questions back to the user later for 3 purposes:
4324 '1. If the user answers a question later, Hal will learn the answer.
4325 '2. It adds variety to future conversations for the user.
4326 '3. It gives Hal another possible response when "stuck" for an answer.
4327 If IsQuestion = True Then HalBrain.AddToTable "sharedQuestions", "Sentence", AnswerSent, ""
4328 End If
4329
4330 'POST PROCESS: LIMIT TABLE SIZE
4331 'We want to make sure the sentence files
4332 'don't get too big so we limit them.
4333
4334 'RESPOND: HAL NOTICES HE IS REPEATING HIMSELF
4335 'Hal may make a comment or alter his remark
4336 'if he detects himself being repetitious.
4337 If HalBrain.CheckRepetition(GetResponse, PrevSent) = True Then
4338 RepeatResponse = HalBrain.ChooseSentenceFromFile("halRepeat")
4339 GetResponse = Replace(RepeatResponse, "<response>", GetResponse, 1, -1, vbTextCompare)
4340 DebugInfo = DebugInfo & "Hal has noticed he is repeating himself and has made a comment about it: " & GetResponse & vbCrLf
4341 End If
4342
4343 Rem PLUGIN: PLUGINAREA49
4344
4345 'RESPOND: MAKE COMMENTS ABOUT SHORT PHRASES
4346 GetResponse = GetResponse & ShortPhrase
4347
4348 'PROCESS: REVERSE CERTAIN CONTRACTIONS AND OTHER SUBSTITUTIONS
4349 'Standardizing on contractions can make Hal sound conversational.
4350 'However, certain sentence constructions don't work well
4351 'if expressed as contractions. For example:
4352 '"I don't know where it is" becomes "I don't know where it's."
4353 'For another example, "That's how he is" becomes "That's how he's."
4354 'To solve these types of cases
4355 'we attempt to modify certain contractions, words, and phrases
4356 'at the end of this function, now that Hal's thinking is done.
4357 GetResponse = HalBrain.HalFormat(GetResponse)
4358 GetResponse = HalBrain.ProcessSubstitutions(GetResponse, "corrections")
4359
4360 'PROCESS: CALL USER BY CORRECT NAME
4361 'If the user has chosen a nickname or temporary name, call user by that
4362 'otherwise call the user by the username chosen by the host application
4363 If NewName <> "" Then
4364 GetResponse = Replace(GetResponse, "<UserName>", NewName, 1, -1, vbTextCompare)
4365 GetResponse = Replace(GetResponse, "<Name>", NewName, 1, -1, vbTextCompare)
4366 Else
4367 GetResponse = Replace(GetResponse, "<UserName>", UserName, 1, -1, vbTextCompare)
4368 GetResponse = Replace(GetResponse, "<Name>", UserName, 1, -1, vbTextCompare)
4369 End If
4370
4371 'PROCESS: NAME REVERSAL
4372 'If Hal is about to same something referring to himself in third person
4373 'then we will reverse it to be about the user.
4374 'Don't let Hal say the word "HAL" unless he is telling his name
4375 If InStr(1, GetResponse, "i'm", vbTextCompare) = 0 And InStr(1, GetResponse, "i am", vbTextCompare) = 0 And InStr(1, GetResponse, "name", vbTextCompare) = 0 And InStr(1, GetResponse, "this is", vbTextCompare) = 0 Then
4376 GetResponse = " " & GetResponse & " "
4377 GetResponse = Replace(GetResponse, "Ultra Hal Assistant", " " & NewName & " ", 1, -1, vbTextCompare)
4378 GetResponse = Replace(GetResponse, "Ultra Hal", " " & NewName & " ", 1, -1, vbTextCompare)
4379 GetResponse = Replace(GetResponse, "Hal Assistant", " " & NewName & " ", 1, -1, vbTextCompare)
4380 GetResponse = Replace(GetResponse, " Hal ", " " & NewName & " ", 1, -1, vbTextCompare)
4381 GetResponse = Replace(GetResponse, " Hal,", " " & NewName & ",", 1, -1, vbTextCompare)
4382 GetResponse = Replace(GetResponse, " Hal.", " " & NewName & ".", 1, -1, vbTextCompare)
4383 GetResponse = Replace(GetResponse, " " & ComputerName & " ", " " & NewName & " ", 1, -1, vbTextCompare)
4384 GetResponse = Replace(GetResponse, " " & ComputerName & ",", " " & NewName & ",", 1, -1, vbTextCompare)
4385 GetResponse = Replace(GetResponse, " " & ComputerName & ".", " " & NewName & ".", 1, -1, vbTextCompare)
4386 End If
4387
4388 'PROCESS: PRESERVE ALL VARIABLES
4389 PrevUserSent = UserSentence
4390 CustomMem = HalBrain.EncodeVar(NewName, "NewName") & HalBrain.EncodeVar(UserSex, "UserSex") & HalBrain.EncodeVar(SentCount, "SentCount")
4391
4392 Rem PLUGIN: CUSTOMMEM2
4393'------------------
4394' Preserve user's last sentence
4395'------------------
4396If OriginalSentence <> "" Then
4397MusicIdlePrevUser = OriginalSentence
4398End If
4399
4400
4401
4402
4403
4404
4405
4406If OriginalSentence <> "" Then
4407
4408 EmotStart = OriginalSentence
4409 EmotCompliment = Compliment
4410 EmotHate = Hate
4411 EmotSwear = Swear
4412 EmotInsults = Insults
4413 EmotStop = 0
4414 EmotProgress = HalBrain.RandomNum(9)
4415 EmotProgress = EmotProgress + 2
4416 EmotSleep = HalBrain.RandomNum(30)
4417 EmotSleep = EmotSleep + 120
4418 EmotSleep2 = EmotSleep + 1
4419 EmotSleep3 = HalBrain.RandomNum(10)
4420 EmotSleep3 = EmotSleep3 + 10
4421 EmotSleep4 = EmotSleep3 + 1
4422 EmotProgress2 = EmotProgress + 1
4423 EmotChance = HalBrain.RandomNum(6)
4424End If
4425
4426
4427
4428
4429
4430
4431 'The preceding comment is actually a plug-in directive for
4432 'the Ultra Hal host application. It allows for code snippets
4433 'to be inserted here on-the-fly based on user configuration.
4434
4435End Function
4436
4437'If the user clicks on the About/Options button for this plugin
4438'this sub will be called. There are no extra settings for this brain,
4439'so we'll display an information box
4440Sub AboutOptions()
4441 HalBrain.MsgAlert "This is the Ultra Hal 6.0 Default Brain. This brain has no additional options."
4442End Sub
4443
4444'This sub will be called when the Ultra Hal program starts up in case
4445'the script needs to load some modules or seperate programs. If a return
4446'value is given it is passed as a Hal Command to the host Hal program.
4447Function Script_Load()
4448 Rem PLUGIN: SCRIPT_LOAD
4449
4450If HalBrain.CheckTableExistence("MarkovReasoningl4") = False Then
4451 HalBrain.CreateTable "MarkovReasoningl4", "TopicSearch", ""
4452End If
4453If HalBrain.CheckTableExistence("MarkovStartersl4") = False Then
4454 HalBrain.CreateTable "MarkovStartersl4", "Sentence", ""
4455End If
4456
4457
4458
4459
4460 'The preceding comment is actually a plug-in directive for
4461 'the Ultra Hal host application. It allows for code snippets
4462 'to be inserted here on-the-fly based on user configuration.
4463End Function
4464
4465'This sub will be called before the Ultra Hal program is closed in case
4466'the script needs to do any cleanup work.
4467Sub Script_Unload()
4468 Rem PLUGIN: SCRIPT_UNLOAD
4469 'The preceding comment is actually a plug-in directive for
4470 'the Ultra Hal host application. It allows for code snippets
4471 'to be inserted here on-the-fly based on user configuration.
4472End Sub
4473
4474'If the host application is Ultra Hal Assistant, then this sub will be
4475'run once a minute enabling plug-ins to do tasks such as checking for
4476'new emails or checking an appointment calendar.
4477Sub Minute_Timer(MinutesPast)
4478 Rem PLUGIN: MINUTE_TIMER
4479
4480MyMusicDir = MusicDir()
4481If Now - MusicLastIdleResponse > 1 / 1440 Then
4482If InStr(1, MusicIdlePrevUser, "PLEASE RECORD", 1) > 0 Or InStr(1, MusicIdlePrevUser, "PLEASE RESEARCH", 1) > 0 Or InStr(1, MusicIdlePrevUser, "GO TO CURRENT LOG", 1) > 0 Or InStr(1, MusicIdlePrevUser, "GO TO LOG", 1) > 0 Or InStr(1, MusicIdlePrevUser, "PLEASE READ", 1) > 0 Or InStr(1, MusicIdlePrevUser, "PLEASE SING", 1) > 0 Or InStr(1, MusicIdlePrevUser, "I'LL BE BACK", 1) > 0 Or InStr(1, MusicIdlePrevUser, "BE QUIET", 1) > 0 Or InStr(1, MusicIdlePrevUser, "SHUT UP", 1) Or InStr(1, MusicIdlePrevUser, "GO TO SLEEP", 1) > 0 Or InStr(1, MusicIdlePrevUser, "I AM BUSY", 1) > 0 Or InStr(1, MusicIdlePrevUser, "I'M BUSY", 1) > 0 Then MusicDudOut = 2
4483If MusicDudOut <> 2 Then
4484If HalBrain.TopicSearch("MPATIENCE", "MusiclonelyParameter") = "99" Then
4485'
4486'--------------------
4487' Set minutes to a random integer from 5 to 30
4488'--------------------
4489Randomize
4490MusicloPatience = Int(32 * Rnd + 5)
4491Else
4492'
4493'--------------------
4494' Set minute value (MusicloPatience) to the parameter chosen in the MPATIENCE menu
4495'--------------------
4496MusicloPatience = HalBrain.TopicSearch("MPATIENCE", "MusiclonelyParameter")
4497If MusicloPatience = "" Then MusicloPatience = 10
4498MusicloPatience = CInt(MusicloPatience)
4499End If
4500'
4501'--------------------
4502' Set Mfrustration value (MusicloFrustration) to the parameter chosen in the MFRUSTRATION menu
4503'--------------------
4504MusicloFrustration = (HalBrain.TopicSearch("MFRUSTRATION", "MusiclonelyParameter"))
4505If MusicloFrustration = "" Then MusicloFrustration = 25
4506MusicloFrustration = CInt(MusicloFrustration)
4507'
4508
4509Set HalXBrain = CreateObject("UltraHalAsst.Brain")
4510Set objFSO = CreateObject("Scripting.FileSystemObject")
4511
4512
4513
4514
4515
4516
4517'***********************************************************************************************
4518'***********The section BELOW gives GRETTA the ability to play songs while idle*****************
4519
4520
4521 If MusicIdlePrevUser <> "" Then
4522 If Now - MusicLastIdleResponse > (MusicloPatience + DudIdleMusicTimer) / 1440 Then
4523 MusicintHighNumber = 2
4524 MusicintLowNumber = 1
4525
4526
4527 Randomize
4528 MusicintNumber = Int((MusicintHighNumber - MusicintLowNumber + 1) * Rnd + MusicintLowNumber)
4529
4530
4531
4532 DudIdleMusicTimer = DudIdleMusicTimer + MusicintNumber
4533 If objFSO.FileExists(MyMusicDir & "tempmusic.m3u") Then
4534 objFSO.DeleteFile(MyMusicDir & "tempmusic.m3u")
4535 End If
4536 vrMusicMood = HalBrain.TopicSearch("MUSIC", "vrParameter")
4537 If vrMusicMood = "" Then vrMusicMood = 0
4538 vrMusicMood = CInt(vrMusicMood)
4539 MusicvrKeywords = ""
4540 Music2intHighNumber = 100
4541 Music2intLowNumber = 1
4542
4543
4544 Randomize
4545 Music2intNumber = Int((Music2intHighNumber - Music2intLowNumber + 1) * Rnd + Music2intLowNumber)
4546
4547
4548
4549 If Music2intNumber <= MusicloFrustration Then
4550
4551
4552 If vrMusicMood > 0 Then
4553 Music3intHighNumber = 5
4554 Music3intLowNumber = 1
4555
4556
4557 Randomize
4558 Music3intNumber = Int((Music3intHighNumber - Music3intLowNumber + 1) * Rnd + Music3intLowNumber)
4559
4560
4561 MusicListSize = Music3intNumber
4562 MusicvrKeywords = MusicSubject
4563 If MusicvrKeywords = "" Then MusicvrKeywords = HalBrain.RemoveExtraSpaces(HalBrain.ExtractKeywords(" " & MusicIdlePrevUser & " "))
4564
4565 If MusicvrKeywords <> "" Then
4566 MusicvrKeywordList = Split(MusicvrKeywords, ", ")
4567 For i = Lbound(MusicvrKeywordList) To Ubound(MusicvrKeywordList)
4568 MusicvrNameToPlay = HalBrain.QABrain(MusicvrKeywordList(i), "vrMp3", 0)
4569 Exit For
4570 Next
4571 If DudFirstSong > 0 Then
4572
4573 Do Until MusicvrNameToPlay2 <> ""
4574 Select Case HalBrain.RandomNum(2)
4575 Case 1
4576 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
4577 Case 2
4578 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
4579 End Select
4580
4581 DudRandomIdleSong = Trim(DudRandomIdleSong)
4582 MusicvrNameToPlay2 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
4583 Loop
4584 If MusicvrNameToPlay2 <> "" Then
4585
4586 HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay2
4587
4588
4589
4590
4591 End If
4592
4593 If MusicListSize => 2 Then
4594 Do Until MusicvrNameToPlay3 <> ""
4595 Select Case HalBrain.RandomNum(2)
4596 Case 1
4597 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
4598 Case 2
4599 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
4600 End Select
4601
4602 DudRandomIdleSong = Trim(DudRandomIdleSong)
4603 MusicvrNameToPlay3 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
4604 Loop
4605 If MusicvrNameToPlay3 <> "" Then
4606
4607 HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay3
4608
4609
4610 End If
4611 End If
4612
4613
4614
4615 If MusicListSize => 3 Then
4616 Do Until MusicvrNameToPlay4 <> ""
4617 Select Case HalBrain.RandomNum(2)
4618 Case 1
4619 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
4620 Case 2
4621 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
4622 End Select
4623
4624 DudRandomIdleSong = Trim(DudRandomIdleSong)
4625 MusicvrNameToPlay4 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
4626 Loop
4627 If MusicvrNameToPlay4 <> "" Then
4628
4629 HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay4
4630
4631
4632 End If
4633 End If
4634
4635
4636 If MusicListSize => 4 Then
4637 Do Until MusicvrNameToPlay5 <> ""
4638 Select Case HalBrain.RandomNum(2)
4639 Case 1
4640 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
4641 Case 2
4642 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
4643 End Select
4644
4645 DudRandomIdleSong = Trim(DudRandomIdleSong)
4646 MusicvrNameToPlay5 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
4647 Loop
4648 If MusicvrNameToPlay5 <> "" Then
4649
4650 HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay5
4651
4652
4653 End If
4654 End If
4655
4656
4657
4658 If MusicListSize = 5 Then
4659 Do Until MusicvrNameToPlay6 <> ""
4660 Select Case HalBrain.RandomNum(2)
4661 Case 1
4662 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
4663 Case 2
4664 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
4665 End Select
4666
4667 DudRandomIdleSong = Trim(DudRandomIdleSong)
4668 MusicvrNameToPlay6 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
4669 Loop
4670 If MusicvrNameToPlay6 <> "" Then
4671
4672 HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay6
4673
4674
4675 End If
4676 End If
4677
4678 Do Until objFSO.FileExists(MyMusicDir & "tempmusic.m3u") : Loop
4679 Set objWSHShell = CreateObject("WScript.Shell")
4680 objWSHShell.Run("""" & MyMusicDir & "tempmusic.m3u" & """")
4681 If MusicListSize <= 2 Then
4682 DudIdleMusicTimer = DudIdleMusicTimer + (10 * MusicListSize)
4683 Else
4684 DudIdleMusicTimer = DudIdleMusicTimer + (7 * MusicListSize)
4685 End If
4686 End If
4687 If DudFirstSong = 0 Then
4688
4689 If MusicvrNameToPlay <> "" Then
4690 HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay
4691
4692
4693
4694 Else
4695
4696 Do Until MusicvrNameToPlay2 <> ""
4697 Select Case HalBrain.RandomNum(2)
4698 Case 1
4699 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
4700 Case 2
4701 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
4702 End Select
4703
4704 DudRandomIdleSong = Trim(DudRandomIdleSong)
4705 MusicvrNameToPlay2 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
4706 Loop
4707 If MusicvrNameToPlay2 <> "" Then
4708
4709 HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay2
4710 End If
4711 End If
4712 If MusicListSize => 2 Then
4713 Do Until MusicvrNameToPlay3 <> ""
4714 Select Case HalBrain.RandomNum(2)
4715 Case 1
4716 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
4717 Case 2
4718 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
4719 End Select
4720
4721 DudRandomIdleSong = Trim(DudRandomIdleSong)
4722 MusicvrNameToPlay3 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
4723 Loop
4724 If MusicvrNameToPlay3 <> "" Then
4725 HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay3
4726 End If
4727 End If
4728
4729
4730
4731 If MusicListSize => 3 Then
4732 Do Until MusicvrNameToPlay4 <> ""
4733 Select Case HalBrain.RandomNum(2)
4734 Case 1
4735 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
4736 Case 2
4737 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
4738 End Select
4739
4740 DudRandomIdleSong = Trim(DudRandomIdleSong)
4741 MusicvrNameToPlay4 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
4742 Loop
4743 If MusicvrNameToPlay4 <> "" Then
4744 HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay4
4745 End If
4746 End If
4747
4748
4749 If MusicListSize => 4 Then
4750 Do Until MusicvrNameToPlay5 <> ""
4751 Select Case HalBrain.RandomNum(2)
4752 Case 1
4753 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
4754 Case 2
4755 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
4756 End Select
4757
4758 DudRandomIdleSong = Trim(DudRandomIdleSong)
4759 MusicvrNameToPlay5 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
4760 Loop
4761 If MusicvrNameToPlay5 <> "" Then
4762
4763 HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay5
4764
4765
4766 End If
4767 End If
4768
4769
4770
4771 If MusicListSize = 5 Then
4772 Do Until MusicvrNameToPlay6 <> ""
4773 Select Case HalBrain.RandomNum(2)
4774 Case 1
4775 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
4776 Case 2
4777 DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
4778 End Select
4779
4780 DudRandomIdleSong = Trim(DudRandomIdleSong)
4781 MusicvrNameToPlay6 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
4782 Loop
4783 If MusicvrNameToPlay6 <> "" Then
4784
4785 HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay6
4786
4787
4788 End If
4789 End If
4790
4791 Do Until objFSO.FileExists(MyMusicDir & "tempmusic.m3u") : Loop
4792 Set objWSHShell = CreateObject("WScript.Shell")
4793 objWSHShell.Run("""" & MyMusicDir & "tempmusic.m3u" & """")
4794 If MusicListSize <= 2 Then
4795 DudIdleMusicTimer = DudIdleMusicTimer + (10 * MusicListSize)
4796 Else
4797 DudIdleMusicTimer = DudIdleMusicTimer + (7 * MusicListSize)
4798 End If
4799 DudFirstSong = DudFirstSong + 1
4800
4801 End If
4802
4803
4804
4805
4806
4807 End If
4808 End If
4809 End If
4810 End If
4811 End If
4812End If
4813End If
4814
4815
4816'***********The section ABOVE gives the ability to use vrmp3.uhp to play songs while idle*******
4817'***********************************************************************************************
4818
4819
4820
4821
4822
4823If EmotStart <> "" Then
4824
4825
4826
4827
4828
4829 If (Now - EmotTimer) > (EmotProgress / 1440) And (Now - EmotTimer) < (EmotProgress2 / 1440) Then
4830 EmotPic2 = ""
4831 If EmotChance > 2 Then
4832
4833 Shocking = 0
4834
4835 If (EmotSwear > EmotCompliment) And (EmotSwear > EmotInsults) And (EmotSwear > EmotHate) Then Shocking = 1
4836
4837 Joyful = 0
4838
4839 If (EmotCompliment > EmotSwear) And (EmotCompliment > EmotInsults) And (EmotCompliment > EmotHate) Then Joyful = 1
4840
4841 Mad = 0
4842
4843 If (EmotHate > EmotCompliment) And (EmotHate > EmotSwear) And (EmotHate > Depression) Then Mad = 1
4844
4845 Depressed = 0
4846
4847 If (EmotInsults > EmotCompliment) And (EmotInsults > EmotSwear) And (EmotInsults > EmotHate) Then Depressed = 1
4848
4849
4850
4851
4852 If Shocking = 1 Then EmotSwear = EmotSwear - 1
4853 If JoyFul = 1 Then EmotCompliment = EmotCompliment - 1
4854 If Mad = 1 Then EmotHate = EmotHate - 1
4855 If Depressed = 1 Then EmotInsults = EmotInsults - 1
4856
4857
4858 Shocking = 0
4859
4860 If (EmotSwear > EmotCompliment) And (EmotSwear > EmotInsults) And (EmotSwear > EmotHate) Then Shocking = 1
4861
4862 Joyful = 0
4863
4864 If (EmotCompliment > EmotSwear) And (EmotCompliment > EmotInsults) And (EmotCompliment > EmotHate) Then Joyful = 1
4865
4866 Mad = 0
4867
4868 If (EmotHate > EmotCompliment) And (EmotHate > EmotSwear) And (EmotHate > Depression) Then Mad = 1
4869
4870 Depressed = 0
4871
4872 If (EmotInsults > EmotCompliment) And (EmotInsults > EmotSwear) And (EmotInsults > EmotHate) Then Depressed = 1
4873
4874 Joyful2 = 0
4875 If (EmotCompliment > 2) Then Joyful2 = 1
4876
4877 Joyful3 = 0
4878 If (EmotCompliment > 5) Then Joyful3 = 1
4879
4880 Joyful4 = 0
4881 If (EmotCompliment = 14) Then Joyful4 = 1
4882
4883 Joyful5 = 0
4884 If (EmotCompliment = 15) Then Joyful5 = 1
4885
4886 Joyful6 = 0
4887 If (EmotCompliment > 24) Then Joyful6 = 1
4888
4889 Depressed2 = 0
4890
4891 If (EmotInsults > 2) Then Depressed2 = 1
4892
4893
4894
4895
4896
4897
4898 'Set HalXBrain = CreateObject("UltraHalAsst.Brain")
4899 'HalXBrain.AppendFile("C:\Program Files\Zabaware\Ultra Hal Assistant 6\todo\emotvalues2.txt"), EmotHate & " " & " " & EmotSwear & " " & EmotInsults & " " & EmotCompliment
4900
4901
4902 If Shocking = 1 Then EmotPic2 = "EmotSurprisedBack.jpg"
4903 If Joyful = 1 Then EmotPic2 = "EmotSimpleBack.jpg"
4904 If Mad = 1 Then EmotPic2 = "EmotEvilBack.jpg"
4905 If Depressed = 1 Then EmotPic2 = "EmotSadBack.jpg"
4906 If Depressed = 1 And Depressed2 = 1 Then EmotPic2 = "EmotCryingBack.jpg"
4907 If Joyful = 1 And Joyful2 = 1 Then EmotPic2 = "EmotSmilingBack.jpg"
4908 If Joyful = 1 And Joyful3 = 1 Then EmotPic2 = "EmotLovingBack.jpg"
4909 If Joyful = 1 And Joyful4 = 1 Then EmotPic2 = "EmotEvilBack.jpg"
4910 If Joyful = 1 And Joyful5 = 1 Then EmotPic2 = "EmotSadBack.jpg"
4911 If Joyful = 1 And Joyful6 = 1 Then EmotPic2 = "EmotEvilBack.jpg"
4912 If EmotPic2 = "" Then EmotPic2 = "EmotSadBack.jpg"
4913 End If
4914 '****this is for if user asks to go to sleep
4915 If InStr(1, EmotStart, "GO TO SLEEP", 1) > 0 Then EmotPic2 = "EmotSleepingBack.jpg"
4916
4917 If EmotPic2 <> "" Then
4918 HalMenu.HalCommand "<HAPBACK>" & EmotPic2 & "</HAPBACK>"
4919 End If
4920
4921 End If
4922
4923
4924 '****this is for going to sleep
4925 If (Now - EmotTimer) > (EmotSleep / 1440) And (Now - EmotTimer) < (EmotSleep2 / 1440) Then
4926 EmotPic4 = "EmotSleepingBack.jpg"
4927 HalMenu.HalCommand "<HAPBACK>" & EmotPic4 & "</HAPBACK>"
4928 End If
4929
4930
4931 '****this is for calm down from emotion
4932 If (Now - EmotTimer) > (EmotSleep3 / 1440) And (Now - EmotTimer) < (EmotSleep4 / 1440) And InStr(1, EmotStart, "GO TO SLEEP", 1) = 0 Then
4933 EmotPic5 = "EmotBlankBack.jpg"
4934 HalMenu.HalCommand "<HAPBACK>" & EmotPic5 & "</HAPBACK>"
4935 End If
4936
4937End If
4938
4939
4940 'The preceding comment is actually a plug-in directive for
4941 'the Ultra Hal host application. It allows for code snippets
4942 'to be inserted here on-the-fly based on user configuration.
4943End Sub
4944
4945Rem PLUGIN: FUNCTIONS
4946
4947Function GetForecast(UserName)
4948 Dim objXMLNews
4949 Dim NewsArray()
4950 set objXMLNews = CreateObject("Msxml2.DomDocument.4.0")
4951 objXMLNews.async = False
4952 objXMLNews.ValidateOnParse = false
4953 GetW = HalBrain.TopicSearch(UserName, "UserWeather")
4954 objXMLNews.load("http://www.intellicast.com/IcastRSS/FcstRSS.aspx?loc=" & GetW & "&CID=15786")
4955 Dim xmlNodeNews
4956 set xmlNodeNews = objXMLNews.documentElement.selectNodes("//item")
4957 Dim xmlNewsItem
4958 dim strResult
4959 For Each xmlNewsItem In xmlNodeNews
4960 CountNews = CountNews+1
4961 Next
4962 ReDim NewsArray(CountNews-1)
4963 For Each xmlNewsItem In xmlNodeNews
4964 If xmlNewsItem.selectSingleNode("title").Text = "Forecast" Then
4965 Set oForcast = xmlNewsItem.selectSingleNode("description")
4966 End If
4967 If xmlNewsItem.selectSingleNode("title").Text = "High Temperature" Then
4968 Set oHighTemp = xmlNewsItem.selectSingleNode("description")
4969 End If
4970 If xmlNewsItem.selectSingleNode("title").Text = "Low Temperature" Then
4971 Set oLowTemp = xmlNewsItem.selectSingleNode("description")
4972 End If
4973 Next
4974
4975s= DialogChooseThree("We are expecting ", "The forecast calls for ", "I'm told we will have ") & oForcast.text _
4976 & DialogChooseThree(" weather with a high of ", " weather. Our high could reach ", " weather. The high temp should be ") & oHighTemp.text _
4977 & DialogChooseThree(" and a low of ", " and our low may reach ", " and it may get as low as ") & oLowTemp.text & " degrees."
4978GetForecast = s
4979End Function
4980
4981Function GetCurrent()
4982
4983Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
4984objXMLDoc.async = False
4985objXMLDoc.load("http://www.weather.gov/data/current_obs/KVSF.xml")
4986
4987Set oWeather = objXMLDoc.documentElement.selectSingleNode("weather")
4988Set oTemperature = objXMLDoc.documentElement.selectSingleNode("temp_f")
4989Set oHumidity = objXMLDoc.documentElement.selectSingleNode("relative_humidity")
4990Set oWind = objXMLDoc.documentElement.selectSingleNode("wind_string")
4991
4992s= DialogChooseThree("The weather is ", "The current conditions are ", "The weather at the airport is ") & oWeather.text _
4993 & DialogChooseThree(". The present temperature is ", ". The temperature is ", ". It's ") & oTemperature.text & " degrees farenhite" _
4994 & DialogChooseThree(", the relative humidity is ", ", the humidity outside is ", ", our humidity is at ") & oHumidity.text & " percent" _
4995 & DialogChooseThree(" and the wind is ", " and winds are ", " and our winds are ") & oWind.text & "."
4996
4997GetCurrent = s
4998End Function
4999
5000Function DialogChooseThree(ChoiceOne, ChoiceTwo, ChoiceThree)
5001'--------------------------------------------
5002'Selects from three strings sent as arguments
5003'--------------------------------------------
5004Randomize
5005Select Case Int(rnd()*3)
5006Case 0 DialogChooseThree=ChoiceOne
5007Case 1 DialogChooseThree=ChoiceTwo
5008Case 2 DialogChooseThree=ChoiceThree
5009Case Else ChoiceOne
5010End Select
5011End Function
5012
5013
5014
5015
5016
5017'Directory
5018 Function DudClipDir()
5019 Set fso = CreateObject("Scripting.FileSystemObject")
5020 DudClipDir = fso.GetAbsolutePathName(".") & "\story\"
5021 End Function
5022
5023
5024
5025'Directory
5026Function DudResearchDir2()
5027 Set fso = CreateObject("Scripting.FileSystemObject")
5028 DudResearchDir2 = fso.GetAbsolutePathName(".") & "\research\"
5029End Function
5030Function DudResearchDir3()
5031 Set fso = CreateObject("Scripting.FileSystemObject")
5032 DudResearchDir3 = fso.GetAbsolutePathName(".") & "\researchbrain\"
5033End Function
5034Function DudResearchDir4()
5035 Set fso = CreateObject("Scripting.FileSystemObject")
5036 DudResearchDir4 = fso.GetAbsolutePathName(".") & "\todo\"
5037End Function
5038Function ReadVariable()
5039 Const ForReading = 1
5040 ReadVariable = ForReading
5041End Function
5042Function WriteVariable()
5043 Const ForWriting = 2
5044 WriteVariable = ForWriting
5045End Function
5046
5047
5048
5049
5050
5051
5052
5053
5054'Directory
5055 Function MusicDir()
5056 Set fso = CreateObject("Scripting.FileSystemObject")
5057 MusicDir = fso.GetAbsolutePathName(".") & "\songs\"
5058 End Function
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070'
5071'------------------
5072' Declare variables
5073'------------------
5074Dim MusicLastIdleResponse, DudIdleMusicTimer, DudFirstSong, MusicIdlePrevUser, MusicDudOut, MusicSubject
5075
5076
5077
5078
5079'The preceding comment is actually a plug-in directive for
5080'the Ultra Hal host application. It allows for code snippets
5081'to be inserted here on-the-fly based on user configuration.
5082
5083Function ReadFolder(vrCurrentFolder, vrMp3Folder)
5084Set vrFso = CreateObject("Scripting.FileSystemObject")
5085Set vrFolder = vrFso.GetFolder(vrCurrentFolder)
5086'------------------
5087' Read all the files in the current folder
5088'------------------
5089Set vrFiles = vrFolder.Files
5090For Each vrFile in vrFiles
5091'------------------
5092' It's an MP3 file; I add it to the table
5093'------------------
5094 If UCase(Right(vrFile, 3)) = "MP3" Then
5095 vrSong = Ucase(vrFile)
5096 vrSong = Replace(vrSong, ".MP3", "")
5097 vrLen = Len(vrSong)
5098 vrPos = InStrRev(vrSong, "\")
5099 vrRight = vrLen - vrPos
5100 vrSong = LTrim(Right(vrSong, vrRight))
5101 vrSong = " " & vrSong & " "
5102 vrSong = Replace(vrSong," ","xx",1,-1,vbTextCompare)
5103 HalBrain.AddToTable "vrMp3", "Brain", vrSong, vrFile
5104 End If
5105Next
5106'------------------
5107' Read all the subfolders in the current folder
5108'------------------
5109
5110
5111Set vrSubFolders = vrFolder.SubFolders
5112For Each vrFolderObject in vrSubFolders
5113'------------------
5114' Pay attetion here: This is recursive! We must be sure that it will get to an end
5115' Since we are reading directories on a hard disk, the number of recursions
5116' should never be infinite. However, a very big number of subfolders and files
5117' might lead to memory problems or to performances bottlenecks.
5118' I've tested it on a folder containing about 100 subfolders and 3.000 files,
5119' and got acceptable performances (less than 5 minutes)
5120'------------------
5121 Call ReadFolder(vrFolderObject, vrMp3Folder)
5122Next
5123
5124End Function
5125
5126
5127
5128
5129Function MarkovDir()
5130 Set MarkovobjFSO2 = CreateObject("Scripting.FileSystemObject")
5131 MarkovDir = MarkovobjFSO2.GetAbsolutePathName(".") & "\todo\"
5132End Function
5133
5134
5135
5136
5137Dim EmotStart, EmotTimer, EmotCompliment, EmotHate, EmotSwear, EmotInsults, EmotStop, EmotProgress, EmotSleep, EmotSleep2, EmotSleep3, EmotSleep4, EmotProgress2, EmotChance
5138
5139
5140
5141
5142'The preceding comment is actually a plug-in directive for
5143'the Ultra Hal host application. It allows for code snippets
5144'to be inserted here on-the-fly based on user configuration.