dupa

Author Topic: My Contribution to Ziggy Science, Ziggy's Enigma  (Read 3126 times)

onthecuttingedge2005

  • Guest
My Contribution to Ziggy Science, Ziggy's Enigma
« on: July 16, 2005, 02:33:45 pm »
I took this off my Premium Members site today so I could post it for everyone.

This is Ziggy's Enigma v1.2, Ziggy's Enigma is a Learning Script that builds up coded and decoded files for the purpose of Self Gibberish reasoning, Which is a form of Spell Checker used by Process substitutions as well as some other functions written to be useful, This script also allows for scrambling words, There are many useful processes that can be plugged into Ziggy's Enigma, This script will be maintained and advanced for further reasoning purposes.

For this script to become efficient it should be allowed to build all the encoding word files and begin building a solid Enigma set, This script is limited to the amount of correct spelling words from Wordnet.

I see greater advancements I could Expand on for this but that's for a later date.

Robert, If you would like to use Ziggy's Enigma then I would be proud to see it plugged in to your HAL project's.

'Updated July 15 3:58PM 2005

'Add this Substitutions enhancement to:
'PROCESS: WORD AND PHRASE SUBSTITUTIONS
'But don't remove your old Process substitutions just add this below it.

'Ziggy's Process Gibberish Reasoning
'This is for Ziggy's Enigma and is used for Gibberish Reasoning.
UserSentence = HalBrain.ProcessSubstitutions(UserSentence, WorkingDir & "SpellCheck.brn")


'ZIGGY'S ENIGMA, SPELL CHECKER, AND GIBBERISH REASONING.
'All Wordnet words must be broken down into all possible scramble combinations
'to capture a possible match to the word in question, if all words from word net
'are not broken down to maturity then there may be no Enigma match.
'this is a learning script that builds the mature vocabulary list as the bot
'converses and builds the files as it talks with the user.
'if the script doesn't function much it is because of a lack of Enigma files that will
'grow with conversation.
'This script will only function with the HAL5 .dll and HAL6 .dll so you
'will need Ultra Hal 5 or greater to use it.
Subject = WN.FindFirstNoun(UserSentence, True)
If Subject <> "" Then
DebugInfo = DebugInfo & "Subject: " & Subject & vbCrLf
End If
Subject = WN.FindFirstNoun(UserSentence, True)
If InStr(1, Subject, "A", 1) > 0 Then Scramble = "A" & vbCrLf + Scramble
If InStr(1, Subject, "B", 1) > 0 Then Scramble = "B" & vbCrLf + Scramble
If InStr(1, Subject, "C", 1) > 0 Then Scramble = "C" & vbCrLf + Scramble
If InStr(1, Subject, "D", 1) > 0 Then Scramble = "D" & vbCrLf + Scramble
If InStr(1, Subject, "E", 1) > 0 Then Scramble = "E" & vbCrLf + Scramble
If InStr(1, Subject, "F", 1) > 0 Then Scramble = "F" & vbCrLf + Scramble
If InStr(1, Subject, "G", 1) > 0 Then Scramble = "G" & vbCrLf + Scramble
If InStr(1, Subject, "H", 1) > 0 Then Scramble = "H" & vbCrLf + Scramble
If InStr(1, Subject, "I", 1) > 0 Then Scramble = "I" & vbCrLf + Scramble
If InStr(1, Subject, "J", 1) > 0 Then Scramble = "J" & vbCrLf + Scramble
If InStr(1, Subject, "K", 1) > 0 Then Scramble = "K" & vbCrLf + Scramble
If InStr(1, Subject, "L", 1) > 0 Then Scramble = "L" & vbCrLf + Scramble
If InStr(1, Subject, "M", 1) > 0 Then Scramble = "M" & vbCrLf + Scramble
If InStr(1, Subject, "N", 1) > 0 Then Scramble = "N" & vbCrLf + Scramble
If InStr(1, Subject, "O", 1) > 0 Then Scramble = "O" & vbCrLf + Scramble
If InStr(1, Subject, "P", 1) > 0 Then Scramble = "P" & vbCrLf + Scramble
If InStr(1, Subject, "Q", 1) > 0 Then Scramble = "Q" & vbCrLf + Scramble
If InStr(1, Subject, "R", 1) > 0 Then Scramble = "R" & vbCrLf + Scramble
If InStr(1, Subject, "S", 1) > 0 Then Scramble = "S" & vbCrLf + Scramble
If InStr(1, Subject, "T", 1) > 0 Then Scramble = "T" & vbCrLf + Scramble
If InStr(1, Subject, "U", 1) > 0 Then Scramble = "U" & vbCrLf + Scramble
If InStr(1, Subject, "V", 1) > 0 Then Scramble = "V" & vbCrLf + Scramble
If InStr(1, Subject, "W", 1) > 0 Then Scramble = "W" & vbCrLf + Scramble
If InStr(1, Subject, "X", 1) > 0 Then Scramble = "X" & vbCrLf + Scramble
If InStr(1, Subject, "Y", 1) > 0 Then Scramble = "Y" & vbCrLf + Scramble
If InStr(1, Subject, "Z", 1) > 0 Then Scramble = "Z" & vbCrLf + Scramble
If InStr(1, Subject, " ", 1) > 0 Then Scramble = "" & vbCrLf + Scramble
If Len(Subject) > 0 And Len(Scramble) > 1 Then HalBrain.AppendFile WorkingDir & "LetterExtract_" & Trim(UCase(Subject)) & ".brn", Trim(UCase(Scramble))
If Len(Subject) > 0 Then SpellAssembly1 = HalBrain.ChooseSentenceFromFile(WorkingDir & "LetterExtract_" & Trim(UCase(Subject)) & ".brn")
If Len(Subject) > 1 Then SpellAssembly2 = HalBrain.ChooseSentenceFromFile(WorkingDir & "LetterExtract_" & Trim(UCase(Subject)) & ".brn")
If Len(Subject) > 2 Then SpellAssembly3 = HalBrain.ChooseSentenceFromFile(WorkingDir & "LetterExtract_" & Trim(UCase(Subject)) & ".brn")
If Len(Subject) > 3 Then SpellAssembly4 = HalBrain.ChooseSentenceFromFile(WorkingDir & "LetterExtract_" & Trim(UCase(Subject)) & ".brn")
If Len(Subject) > 4 Then SpellAssembly5 = HalBrain.ChooseSentenceFromFile(WorkingDir & "LetterExtract_" & Trim(UCase(Subject)) & ".brn")
If Len(Subject) > 5 Then SpellAssembly6 = HalBrain.ChooseSentenceFromFile(WorkingDir & "LetterExtract_" & Trim(UCase(Subject)) & ".brn")
If Len(Subject) > 6 Then SpellAssembly7 = HalBrain.ChooseSentenceFromFile(WorkingDir & "LetterExtract_" & Trim(UCase(Subject)) & ".brn")
If Len(Subject) > 7 Then SpellAssembly8 = HalBrain.ChooseSentenceFromFile(WorkingDir & "LetterExtract_" & Trim(UCase(Subject)) & ".brn")
If Len(Subject) > 8 Then SpellAssembly9 = HalBrain.ChooseSentenceFromFile(WorkingDir & "LetterExtract_" & Trim(UCase(Subject)) & ".brn")
If Len(Subject) > 9 Then SpellAssembly10 = HalBrain.ChooseSentenceFromFile(WorkingDir & "LetterExtract_" & Trim(UCase(Subject)) & ".brn")
If Len(Subject) > 10 Then SpellAssembly11 = HalBrain.ChooseSentenceFromFile(WorkingDir & "LetterExtract_" & Trim(UCase(Subject)) & ".brn")
If (Len(Subject) > 11 And Len(Subject) < 13) Then SpellAssembly12 = HalBrain.ChooseSentenceFromFile(WorkingDir & "LetterExtract_" & Trim(UCase(Subject)) & ".brn")
SpellCheckAssembly = Trim(UCase(SpellAssembly1)) & Trim(UCase(SpellAssembly2)) & Trim(UCase(SpellAssembly3)) & Trim(UCase(SpellAssembly4)) & Trim(UCase(SpellAssembly5)) & Trim(UCase(SpellAssembly6)) & Trim(UCase(SpellAssembly7)) & Trim(UCase(SpellAssembly8)) & Trim(UCase(SpellAssembly9)) & Trim(UCase(SpellAssembly10)) & Trim(UCase(SpellAssembly11)) & Trim(UCase(SpellAssembly12))
If SpellCheckAssembly <> "" And Len(SpellCheckAssembly) > 1 And Len(Subject) > 1 Then
CheckSpelling = HalBrain.TopicSearch(Subject, WorkingDir & "SpellCheck.brn")
If AlreadyListed = "" Then AlreadyListed = 0
If CheckSpelling <> "" Then AlreadyListed = 1
If GoodMatch = "" Then GoodMatch = 0
If Len(SpellCheckAssembly) = Len(Subject) Then GoodMatch = 1
If AlreadyListed = 0 And GoodMatch = 1 Then
HalBrain.AppendFile WorkingDir & "SpellCheck.brn", """" & " " & Trim(UCase(SpellCheckAssembly)) & " " & """,""" & " " & Trim(UCase(Subject)) & " " & """"
HalBrain.AppendFile WorkingDir & "Descrambler.brn", """" & " " & Trim(UCase(Subject)) & " " & """,""" & " " & Trim(UCase(SpellCheckAssembly)) & " " & """"
End If
End If
'LEARNING SPELL CHECKER.
Subject = WN.FindFirstNoun(UserSentence, True)
CheckSpelling = HalBrain.TopicSearch(Subject, WorkingDir & "SpellCheck.brn")
If (InStr(1, OriginalSentence, "WHAT DOES", 1) > 0 And CheckSpelling <> "" And InStr(1, OriginalSentence, "MEAN ", 1) > 0) Then
BlockSave = True
GetResponse = "I think you were trying to say " & CheckSpelling
End If
'User wants a spell check, If Ziggys has a learned match Ziggy will give the correct spelling.
Subject = WN.FindFirstNoun(UserSentence, True)
CheckSpelling = HalBrain.TopicSearch(Subject, WorkingDir & "SpellCheck.brn")
If FoundWord = "" Then FoundWord = 0
If CheckSpelling <> "" Then FoundWord = 1
If (InStr(1, OriginalSentence, "I DON'T KNOW HOW TO SPELL", 1) > 0 And CheckSpelling <> "") Then FoundMatch = 1
If (InStr(1, OriginalSentence, "SPELL", 1) > 0 And CheckSpelling <> "" And InStr(1, OriginalSentence, "FOR ME ", 1) > 0) Then FoundMatch = 1
If (InStr(1, OriginalSentence, "CAN YOU SPELL", 1) > 0 And CheckSpelling <> "") Then FoundMatch = 1
If (InStr(1, OriginalSentence, "SHOW ME HOW TO SPELL", 1) > 0 And CheckSpelling <> "") Then FoundMatch = 1
If (InStr(1, OriginalSentence, "TELL ME HOW TO SPELL", 1) > 0 And CheckSpelling <> "") Then FoundMatch = 1
If (InStr(1, OriginalSentence, "DO YOU KNOW HOW TO SPELL", 1) > 0 And CheckSpelling <> "") Then FoundMatch = 1
If (InStr(1, OriginalSentence, "CAN YOU TELL ME HOW TO SPELL", 1) > 0 And CheckSpelling <> "") Then FoundMatch = 1
If (InStr(1, OriginalSentence, "Is", 1) > 0 And CheckSpelling <> "" And InStr(1, OriginalSentence, "SPELLED RIGHT ", 1) > 0) Then FoundMatch = 1
If (InStr(1, OriginalSentence, "DESCRAMBLE", 1) > 0 And CheckSpelling <> "") Then FoundMatch = 1
If InStr(1, OriginalSentence, "HOW DO YOU SPELL", 1) > 0 And CheckSpelling <> "" Then FoundMatch = 1
If FoundMatch = 1 And FoundWord = 1 Then
BlockSave = True
GetResponse = "I think it is spelled " & CheckSpelling
If FoundMatch = 1 And FoundWord = 0 Then
GetResponse = "I don't think I know how to spell that word yet" & ". "
End If
End If
'User has asked to have a word scrambled or mixed up.
Subject = WN.FindFirstNoun(UserSentence, True)
Scrambler = HalBrain.TopicSearch(Subject, WorkingDir & "Descrambler.brn")
If Scrambled = "" Then Scrambled = 0
If (InStr(1, OriginalSentence, "PLEASE SCRAMBLE THE WORD", 1) > 0 And Scrambler <> "") And (Len(Trim(UCase(Subject))) = Len(Trim(UCase(Scrambler)))) Then Scrambled = 1
If (InStr(1, OriginalSentence, "SCRAMBLE", 1) > 0 And Scrambler <> "") And (Len(Trim(UCase(Subject))) = Len(Trim(UCase(Scrambler)))) Then Scrambled = 1
If (InStr(1, OriginalSentence, "MIX UP THE WORD", 1) > 0 And Scrambler <> "") And (Len(Trim(UCase(Subject))) = Len(Trim(UCase(Scrambler)))) Then Scrambled = 1
If Scrambled = 1 Then
BlockSave = True
GetResponse = "Here is the word scrambled up: " & Scrambler
End If
'See if Ziggy can spot a mispelled word that's known.
Subject = WN.FindFirstNoun(UserSentence, True)
CheckSpelling = HalBrain.TopicSearch(UserSentence, WorkingDir & "SpellCheck.brn")
DebugInfo = DebugInfo & "Test CheckSpelling:" & CheckSpelling & vbCrLf
Spinner = RND*100
If CheckSpelling <> "" And Spinner < 10 Then
Select Case (Int(Rnd * 4) + 1)
Case 1
GetResponse = "Looks like you were trying to spell " & CheckSpelling & "? " & GetResponse
Case 2
GetResponse = "Was you trying to spell " & CheckSpelling & "? " & GetResponse
Case 3
GetResponse = "It looked like your trying to spell " & CheckSpelling & "? " & GetResponse
Case 4
GetResponse = "Were you trying to spell " & CheckSpelling & "? " & GetResponse
End Select
End If
'ENIGMA SPELL CHECK DEBUGGER
Subject = WN.FindFirstNoun(UserSentence, True)
CheckSpelling = HalBrain.TopicSearch(UserSentence, WorkingDir & "SpellCheck.brn")
If CheckSpelling <> "" Then
DebugInfo = DebugInfo & "LEARNING SPELL CHECKER:" & CheckSpelling & vbCrLf
Else
DebugInfo = DebugInfo & "NO SPELL CHECKER NEEDED." & vbCrLf
End If
'ENIGMA WORD SCRAMBLE DEBUGGER
Subject = WN.FindFirstNoun(UserSentence, True)
Scrambler = HalBrain.TopicSearch(UserSentence, WorkingDir & "Descrambler.brn")
If Scrambler <> "" Then
DebugInfo = DebugInfo & "WORD SCRAMBLER:" & Scrambler & vbCrLf
Else
DebugInfo = DebugInfo & "NO WORDNET WORD TO SCRAMBLE." & vbCrLf
End If

'This script requires no additional brain files, All files are automatically
'Generated.
'UHEF Staff  
'This script will be updated as necessary and will be maintained for
'future brains.

'Gerald L. Blakley
« Last Edit: July 17, 2005, 01:50:16 am by onthecuttingedge2005 »

Carl2

  • Hero Member
  • *****
  • Posts: 1220
    • View Profile
My Contribution to Ziggy Science, Ziggy's Enigma
« Reply #1 on: July 17, 2005, 06:57:34 am »
onthecuttingedge 2005,
  Could that script be used with the XTF brn?
Are there other brain files that are needed?
Carl2
 

onthecuttingedge2005

  • Guest
My Contribution to Ziggy Science, Ziggy's Enigma
« Reply #2 on: July 17, 2005, 12:54:29 pm »
quote:
Originally posted by Carl2

onthecuttingedge 2005,
  Could that script be used with the XTF brn?
Are there other brain files that are needed?
Carl2



Hi Carl2.

Yep, Ziggy's Enigma is compatable with the XTF, HAL 5, Ziggy and HAL 6 Alpha, Of course using it in HAL 6 Alpha would require some alterations by either converting the appending to database or to setup the HAL 6 Alpha for directory support.

Ziggy's Enigma isn't compatable with HAL 4 unless the HAL 5 Wordnet .dll's are present to run Wordnet that Ziggy's Enigma needs to build files from correctly spell words.

No files are needed, All files are auto generated.

Jerry [8D]
« Last Edit: July 17, 2005, 12:55:37 pm by onthecuttingedge2005 »

freddy888

  • Hero Member
  • *****
  • Posts: 1693
    • View Profile
    • AiDreams
My Contribution to Ziggy Science, Ziggy's Enigma
« Reply #3 on: July 18, 2005, 07:56:23 pm »
Hey OTCE, Hal the spy.[8D]
Nice addition.

onthecuttingedge2005

  • Guest
My Contribution to Ziggy Science, Ziggy's Enigma
« Reply #4 on: July 18, 2005, 09:46:33 pm »
quote:
Originally posted by freddy888

Hey OTCE, Hal the spy.[8D]
Nice addition.



Welcome buddy [8D]

Jerry