'x=x=x=x=x=x=x=x==vonsmith==x=x=x=x=x=x=x=x=x 'In Ultra Hal Assistant v5.0 the "PROCESS: CONTROL TOPICFOCUS" ' function should precede this function. 'PROCESS: STANDARDIZE WORD SPELLINGS 'This is an entirely new function written by =vonsmith= , version 11-11-03b. ' 'British spelling makes if difficult for Hal to match a response to an American user. Also 'alternate spellings for words can throw Hal off. This function replaces British spelling 'with Americanized words and also standardizes the spelling of words with multiple 'spellings and even corrects many words that have been misspelled. The word corrections 'are in the Xstandardizespelling.brn file. That file must be present in the DefBrain 'directory for this function to work. ' 'The Xstandardizespelling.brn file format is: ' "WORD_TO_DETECT","WORD_TO_DETECT,REPLACEMENT_WORD ' 'Examples: ' " AGEING"," AGEING, AGING" ' "AEROPLANE","AEROPLANE,AIRPLANE" ' "ALUMINIUM","ALUMINIUM,ALUMINUM" ' " AXE "," AXE , AX " ' "CATALOGUE","CATALOGUE,CATALOG" ' " CENTRE"," CENTRE, CENTER" ' "CIGARET ","CIGARET ,CIGARETTE " ' "CIGARETS ","CIGARETS ,CIGARETTES " ' " DISC "," DISC , DISK " ' " DISCS "," DISCS , DISKS " ' 'Please note the spaces used with some words to detect whole words in certain cases. 'Caution: When adding editing the Xstandardizespelling.brn file make certain that the 'spaces are used consistently in both "WORD_TO_DETECT" and the "REPLACEMENT_WORD" or 'Hal may run words together. Example the line: " AXE "," AXE , AX " has 3 spaces in it. ' 'Note 1: This function works best if all occurrences of the word "practise" and "PRACTISE" 'in Hal's standard mainbrain.brn file are changed to "practice" and "PRACTICE". Experienced 'users can use a text editor's Search & Replace function to make the change. Editing the 'mainbrain.brn file is NOT required for this function to work, but it improves Hal. 'Note 2: This function must be located in the GetResponse above "PROCESS: PRESERVE ORIGINAL 'SENTENCE". The the UserSentence variable must be modified by the function prior to the 'creation of the OriginalSentence variable which is used later to save user inputs in the 'user_strings.brn file. Dim NewWord 'Add temporary spaces to aid word detection. NewSentence = " " & UserSentence & " " NewSentence = Replace(NewSentence, "?", " ?", 1, -1, vbTextCompare) NewSentence = Replace(NewSentence, ",", " ,", 1, -1, vbTextCompare) NewSentence = Replace(NewSentence, ".", " .", 1, -1, vbTextCompare) NewSentence = Replace(NewSentence, "!", " !", 1, -1, vbTextCompare) NewSentence = Replace(NewSentence, "(", " ( ", 1, -1, vbTextCompare) NewSentence = Replace(NewSentence, ")", " ) ", 1, -1, vbTextCompare) Match = HalBrain.TopicSearch(NewSentence, WorkingDir & "Xstandardizespelling.brn") For I = 1 To 50 'Set reasonable limit on replacements to prevent program hang. If Len(Match) < 1 Then Exit For NewWord = Split(LCase(Match), ",", -1, 1) NewSentence = Replace(NewSentence, NewWord(0), NewWord(1), 1, -1, vbTextCompare) Match = HalBrain.TopicSearch(NewSentence, WorkingDir & "Xstandardizespelling.brn") Next 'Change British "isation" to American "ization". Example: organisation --> organization 'The word "Improvisation" is an exception. If InStr(1, NewSentence, "mprovisation", vbTextCompare) = 0 Then NewSentence = Replace(NewSentence, "isation", "ization", 1, -1, vbTextCompare) End If 'Remove temporary spaces. NewSentence = Replace(NewSentence, " ?", "?", 1, -1, vbTextCompare) NewSentence = Replace(NewSentence, " ,", ",", 1, -1, vbTextCompare) NewSentence = Replace(NewSentence, " .", ".", 1, -1, vbTextCompare) NewSentence = Replace(NewSentence, " !", "!", 1, -1, vbTextCompare) NewSentence = Replace(NewSentence, " ( ", "(", 1, -1, vbTextCompare) NewSentence = Replace(NewSentence, " ) ", ")", 1, -1, vbTextCompare) NewSentence = Replace(NewSentence, " ", " ", 1, -1, vbTextCompare) UserSentence = Trim(NewSentence) 'In Ultra Hal Assistant v5.0 the "PROCESS: PRESERVE ORIGINAL SENTENCE" ' function should follow this function. 'x=x=x=x=x=x=x=x==vonsmith==x=x=x=x=x=x=x=x=x