dupa

Author Topic: New Advanced Corrections  (Read 2807 times)

onthecuttingedge2005

  • Guest
New Advanced Corrections
« on: January 08, 2006, 09:30:54 pm »
POST UPDATE: Jan 9 12:43PM 2006

Here is the newer version of self corrections.
Insert this into your HAL 6 brain.


Code: [Select]
'ZIGGY'S ADVANCED CORRECTIONS FOR HAL 6.
    'YOU WILL HAVE TO DELETE YOUR EXISTING CORRECTIONS TABLE FOR THIS TO FUNCTION.
    'THE PRE EXISTING ZABAWARE CORRECTIONS TABLE CANNOT BE WRITTEN TO BECAUSE IT
    'PRE EXISTED.
    If HalBrain.CheckTableExistence("corrections") = False Then HalBrain.CreateTable "corrections", "TopicSearch", ""
    'Ziggy Pro Bot, Taught corrections.
    If LeftCorr = "" Then LeftCorr = HalBrain.SearchPattern(OriginalSentence, "REPLACE * WITH *", 1)
    If RightCorr = "" Then RightCorr = HalBrain.SearchPattern(OriginalSentence, "REPLACE * WITH *", 2)
    If LeftCorr = "" Then LeftCorr = HalBrain.SearchPattern(OriginalSentence, "IT IS IMPROPER TO SAY * THE PROPER WAY IS TO SAY *", 1)
    If RightCorr = "" Then RightCorr = HalBrain.SearchPattern(OriginalSentence, "IT IS IMPROPER TO SAY * THE PROPER WAY IS TO SAY *", 2)
    If LeftCorr = "" Then LeftCorr = HalBrain.SearchPattern(OriginalSentence, "* IS IMPROPER GRAMMER, THE CORRECT WAY IS TO SAY *", 1)
    If RightCorr = "" Then RightCorr = HalBrain.SearchPattern(OriginalSentence, "* IS IMPROPER GRAMMER, THE CORRECT WAY IS TO SAY *", 2)
    If LeftCorr = "" Then LeftCorr = HalBrain.SearchPattern(OriginalSentence, "* IS SPELLED WRONG, IT IS SPELLED *", 1)
    If RightCorr = "" Then RightCorr = HalBrain.SearchPattern(OriginalSentence, "* IS SPELLED WRONG, IT IS SPELLED *", 2)
    If LeftCorr = "" Then LeftCorr = HalBrain.SearchPattern(OriginalSentence, "PLEASE CORRECT * WITH *", 1)
    If RightCorr = "" Then RightCorr = HalBrain.SearchPattern(OriginalSentence, "PLEASE CORRECT * WITH *", 2)
    If LeftCorr = "" Then LeftCorr = HalBrain.SearchPattern(OriginalSentence, "YOU SPELLED * WRONG, IT IS SPELLED *", 1)
    If RightCorr = "" Then RightCorr = HalBrain.SearchPattern(OriginalSentence, "YOU SPELLED * WRONG, IT IS SPELLED *", 2)
    If LeftCorr = "" Then LeftCorr = HalBrain.SearchPattern(OriginalSentence, "* IS BAD GRAMMER, THE CORRECT WAY IS *", 1)
    If RightCorr = "" Then RightCorr = HalBrain.SearchPattern(OriginalSentence, "* IS BAD GRAMMER, THE CORRECT WAY IS *", 2)
    If LeftCorr = "" Then LeftCorr = HalBrain.SearchPattern(OriginalSentence, "* IS BAD GRAMMER, THE CORRECT WAY TO SAY IT IS *", 1)
    If RightCorr = "" Then RightCorr = HalBrain.SearchPattern(OriginalSentence, "* IS BAD GRAMMER, THE CORRECT WAY TO SAY IT IS *", 2)
    LeftCorr = HalBrain.AlphaNumericalOnly(LeftCorr)
    RightCorr = HalBrain.AlphaNumericalOnly(RightCorr)
    If LeftCorr <> "" And RightCorr <> "" And Len(LeftCorr) > 0 And Len(RightCorr) > 0 Then
    GetResponse = RightCorr & ", I'll make a note of that."
    'TAGS ARE USED FOR HIGHER ACCURACY
    'TAG LEFT
    LeftCorr = "[" & LeftCorr & "]"
    RightCorr = "[" & RightCorr & "]"
    TagLeftCorr = Replace(LeftCorr, " ", "][", 1, -1, vbTextCompare)
    TagLeftCorr = Replace(TagLeftCorr, "\", "][, ", 1, -1, vbTextCompare)
    TagLeftCorr = Replace(TagLeftCorr, "/", "][, ", 1, -1, vbTextCompare)
    TagLeftCorr = Replace(TagLeftCorr, ",", "][, ", 1, -1, vbTextCompare)
    TagLeftCorr = Replace(TagLeftCorr, ".", "][. ", 1, -1, vbTextCompare)
    TagLeftCorr = Replace(TagLeftCorr, "!", "][! ", 1, -1, vbTextCompare)
    TagLeftCorr = Replace(TagLeftCorr, "?", "][? ", 1, -1, vbTextCompare)
    TagLeftCorr = Replace(TagLeftCorr, "'D", "]['D ", 1, -1, vbTextCompare)
    TagLeftCorr = Replace(TagLeftCorr, "'LL", "]['LL ", 1, -1, vbTextCompare)
    TagLeftCorr = Replace(TagLeftCorr, "'S", "]['S ", 1, -1, vbTextCompare)
    TagLeftCorr = Replace(TagLeftCorr, "'M", "]['M ", 1, -1, vbTextCompare)
    TagLeftCorr = Replace(TagLeftCorr, "'T", "]['T ", 1, -1, vbTextCompare)
    TagLeftCorr = Replace(TagLeftCorr, "'RE", "]['RE ", 1, -1, vbTextCompare)
    TagLeftCorr = Replace(TagLeftCorr, "[]", "", 1, -1, vbTextCompare)
    'TAG RIGHT
    TagRightCorr = Replace(RightCorr, " ", "][", 1, -1, vbTextCompare)
    TagRightCorr = Replace(TagRightCorr, "\", "][, ", 1, -1, vbTextCompare)
    TagRightCorr = Replace(TagRightCorr, "/", "][, ", 1, -1, vbTextCompare)
    TagRightCorr = Replace(TagRightCorr, ",", "][, ", 1, -1, vbTextCompare)
    TagRightCorr = Replace(TagRightCorr, ".", "][. ", 1, -1, vbTextCompare)
    TagRightCorr = Replace(TagRightCorr, "!", "][! ", 1, -1, vbTextCompare)
    TagRightCorr = Replace(TagRightCorr, "?", "][? ", 1, -1, vbTextCompare)
    TagRightCorr = Replace(TagRightCorr, "'D", "]['D ", 1, -1, vbTextCompare)
    TagRightCorr = Replace(TagRightCorr, "'LL", "]['LL ", 1, -1, vbTextCompare)
    TagRightCorr = Replace(TagRightCorr, "'S", "]['S ", 1, -1, vbTextCompare)
    TagRightCorr = Replace(TagRightCorr, "'M", "]['M ", 1, -1, vbTextCompare)
    TagRightCorr = Replace(TagRightCorr, "'T", "]['T ", 1, -1, vbTextCompare)
    TagRightCorr = Replace(TagRightCorr, "'RE", "]['RE ", 1, -1, vbTextCompare)
    TagRightCorr = Replace(TagRightCorr, "[]", "", 1, -1, vbTextCompare)
    HalBrain.AddToTable "corrections", "TopicSearch", Trim(TagLeftCorr), Trim(TagRightCorr)
    End If
   
    Rem PLUGIN: POST-PROCESS
       
    'PROCESS: REVERSE CERTAIN CONTRACTIONS AND OTHER SUBSTITUTIONS
    'Standardizing on contractions can make Hal sound conversational.
    'However, certain sentence constructions don't work well
    'if expressed as contractions.  For example:
    '"I don't know where it is" becomes "I don't know where it's."
    'For another example, "That's how he is" becomes "That's how he's."
    'To solve these types of cases
    'we attempt to modify certain contractions, words, and phrases
    'at the end of this function, now that Hal's thinking is done.
    GetResponse = Trim(GetResponse)
    GetResponse = "[" & GetResponse & "]"
    GetResponse = Replace(GetResponse, " ", "][", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, "\", "][, ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, "/", "][, ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, ",", "][, ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, ".", "][. ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, "!", "][! ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, "?", "][? ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, "'D", "]['D ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, "'LL", "]['LL ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, "'S", "]['S ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, "'M", "]['M ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, "'T", "]['T ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, "'RE", "]['RE ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, "[]", "", 1, -1, vbTextCompare)
    If GetResponse = "" Then GetResponse = HalBrain.ProcessSubstitutions(GetResponse, "corrections")
    GetResponse = HalBrain.HalFormat(GetResponse)
    'REMOVE ANY TAGS FROM GETRESPONSE.
    GetResponse = Replace(GetResponse, "[]", "", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, "][", " ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, "[", " ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, "]", " ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, " , ", ", ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, " .", ".", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, " !", "!", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, " ?", "?", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, " 'D ", "'d ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, " 'LL ", "'ll ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, " 'S ", "'s ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, " 'M ", "'m ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, " 'T ", "'t ", 1, -1, vbTextCompare)
    GetResponse = Replace(GetResponse, " 'RE ", "'re ", 1, -1, vbTextCompare)
    GetResponse = GetResponse
    HalBrain.DebugWatch GetResponse, "Correct Response"    

Just replace your existing:
Code: [Select]
'PROCESS: REVERSE CERTAIN CONTRACTIONS AND OTHER SUBSTITUTIONS
    'Standardizing on contractions can make Hal sound conversational.
    'However, certain sentence constructions don't work well
    'if expressed as contractions.  For example:
    '"I don't know where it is" becomes "I don't know where it's."
    'For another example, "That's how he is" becomes "That's how he's."
    'To solve these types of cases
    'we attempt to modify certain contractions, words, and phrases
    'at the end of this function, now that Hal's thinking is done.
    GetResponse = HalBrain.HalFormat(GetResponse)
    GetResponse = HalBrain.ProcessSubstitutions(GetResponse, "corrections")

With my addition, Please note, Your existing corrections table must
be deleted or this script will not write to it.

You will have to reboot HAL 6 Assistant and or AIM Bot after insertion.

You will have to re-teach HAL/Ziggy any improper to proper grammer that was in the previous corrections table.

FAQ
Why do we use tags?

We use Tags because using spaces has so many difficulties in the VbScript functions detecting the correct keyword, Especially if single
letters are used like: "R u a Wat?", Well then, How do Tags do any better, [R][A][WAT][?], All spaces are converted to Tags because Tags have better marking capability especially when using single slang letters as words, there are many more benifits to using tags.

Using Spaces leads to the path of false triggers.

From now on, My work will be based on Tagged strings which has a higher accuracy count then VbtextCompare or Compare and any others that I have tested for keyword accuracy.

Take control of your text, Tag it!

Jerry[8D]
« Last Edit: January 09, 2006, 04:00:02 pm by onthecuttingedge2005 »