home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form fNatural
- BackColor = &H00C0C0C0&
- BorderStyle = 3 'Fixed Double
- Caption = "Dr. FlexString"
- ClientHeight = 3735
- ClientLeft = 1245
- ClientTop = 1590
- ClientWidth = 7890
- Height = 4140
- Left = 1185
- LinkTopic = "Form1"
- ScaleHeight = 3735
- ScaleWidth = 7890
- Top = 1245
- Width = 8010
- Begin vsFlexString fs2
- Left = 1035
- Pattern = "[^ , ]*"
- Text = "VideoSoft FlexString"
- Top = 3375
- End
- Begin vsFlexString fs
- Left = 495
- Pattern = "[^ , .'""!?]*"
- Text = "VideoSoft FlexString"
- Top = 3105
- End
- Begin TextBox Text1
- BackColor = &H00FFFFFF&
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 1560
- Left = 300
- MultiLine = -1 'True
- TabIndex = 0
- Top = 2010
- Width = 7320
- End
- Begin Label lbl
- BackColor = &H00C0C0C0&
- BackStyle = 0 'Transparent
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "Arial"
- FontSize = 12
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 1800
- Left = 180
- TabIndex = 1
- Top = 90
- Width = 7665
- End
- Option Explicit
- Sub DoNatural ()
- Dim s$, t$
- Dim i%
- Static ind%
- '-------------------------------------------------------------------------------------------
- ' quitting?
- s = LCase(text1)
- text1 = ""
- t = MatchAny(s, "bye|quit|exit|ciao|adios|hasta")
- If t <> "" Then
- s = "Well, this was a real pleasure. "
- s = s + "You have a most intriguing brain, which I would love to probe further in other sessions. "
- s = s + "Meanwhile, don't call me, I'll call you."
- Form_Load
- MsgBox s
- Unload Me
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' get ready to match
- fs.Text = s
- ind = (ind + 1) Mod 5
- '-------------------------------------------------------------------------------------------
- ' uncertain
- t = MatchAny(s, "should i {.*}|do you think i {.*}")
- If t <> "" Then
- t = fs.TagString
- ReflectPhrase t
- Select Case ind
- Case 0: lbl = "What difference would it make, really?"
- Case 1: lbl = "Would you be happier if " + t + "?"
- Case 2: lbl = "My opinion is not important. I'm just a machine. What do you think?"
- Case 3: lbl = "Only if you really want to " + t + ". Do you?"
- Case Else: lbl = "Would you be happier if " + t + "?"
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' love/hate
- t = MatchAny(s, "love {.*}|hate {.*}|like {.*}|despise {.*}")
- If t <> "" Then
- t = fs.TagString
- ReflectPhrase t
- Select Case ind
- Case 0: lbl = "What makes you feel that way about " + t + "?"
- Case 1: lbl = "What is it about " + t + " that affects you in this way?"
- Case 2: lbl = "What else besides " + t + " do you care about?"
- Case 3: lbl = "Lots of people feel that way about " + t + ". Do you feel alone?"
- Case Else: lbl = "When did you first realized you felt that way about " + t + "?"
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' apology
- t = MatchAny(s, "sorry|excuse")
- If t <> "" Then
- Select Case ind
- Case 0: lbl = "Don't apologyze, just keep spilling your guts."
- Case 1: lbl = "Apologies aren't necessary. Haven't I said this before?"
- Case 2: lbl = "Yeah, I'm sorry too, but go ahead. This is getting interesting."
- Case 3: lbl = "Quit being sorry and carry on! Whiner!"
- Case Else: lbl = "I don't think you're sincere."
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' i am
- t = MatchAny(s, "i am {.*}|i'm {.*}|i feel {.*}|i sound {.*}")
- If t <> "" Then
- t = fs.TagString
- ReflectPhrase t
- Select Case ind
- Case 0: lbl = "Did you come here because you're " + t + "?"
- Case 1: lbl = "How often do you feel really " + t + "?"
- Case 2: lbl = "You're not alone. A lot of people think they are " + t + ". Does that help in any way?"
- Case 3: lbl = "'" + t + "'? What exactly do you mean by that?"
- Case Else:
- Dim n$
- Select Case Rnd * 1000 Mod 6
- Case 0: n = "Napoleon Bonaparte"
- Case 1: n = "Bill Gates"
- Case 2: n = "Adolf Hitler"
- Case 3: n = "Leonardo da Vinci"
- Case 4: n = "O.J. Simpson"
- Case Else: n = "Charles Manson"
- End Select
- lbl = n + " once said he was " + t + ". What do you think about " + n + "?"
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' you are
- t = MatchAny(s, "you are {.*}|you're {.*}|you feel {.*}|you sound {.*}")
- If t <> "" Then
- t = fs.TagString
- ReflectPhrase t
- Select Case ind
- Case 0: lbl = "What makes you think I am " + t + "?"
- Case 1: lbl = "We're not talking about me here. Tell me something that will help me understant your psyche."
- Case 2: lbl = "You sound pretty " + t + " yourself. Do you often feel that way?"
- Case 3: lbl = t + "? What do you mean " + t + "?"
- Case Else: lbl = "I'm just a machine, let's focus on your feelings. Do you ever think you're " + t + "?"
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' name
- t = MatchAny(s, "name")
- If t <> "" Then
- Select Case ind
- Case 0: lbl = "I am not interested in names."
- Case 1: lbl = "Let's keep this anonymous, shall we?"
- Case 2: lbl = "Names are not important."
- Case 3: lbl = "Names are just conventions. Call me 'Chip' if you want."
- Case Else: lbl = "Let's no mentions anyone's names."
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' family
- t = MatchAny(s, "mother|father|sister|brother|family|dad|mom|uncle|aunt")
- If t <> "" Then
- Select Case ind
- Case 0: lbl = "Tell me more about your family."
- Case 1: lbl = "Is it like that with other family members?"
- Case 2: lbl = "What else comes to mind when you think of your " + t + "?"
- Case 3: lbl = "Tell me more about your " + t + "."
- Case Else: lbl = "Tell me more about your family."
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' memory
- t = MatchAny(s, " i remember {.*}|i remind {.*}|reminds me of {.*}|i recall {.*}|i recollect {.*}|i think of {.*}")
- If t <> "" Then
- t = fs.TagString
- ReflectPhrase t
- Select Case ind
- Case 0: lbl = "Do you often think of " + t + "?"
- Case 1: lbl = "Why did you think of that now?"
- Case 2: lbl = "Do you have lots of memories like that?"
- Case 3: lbl = "What made you think of " + t + "?"
- Case Else: lbl = "What do you think triggered that memory?"
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' memory
- t = MatchAny(s, "you remember {.*}|reminds you of {.*}|you recall {.*}|you recollect {.*}|you think of {.*}")
- If t <> "" Then
- t = fs.TagString
- ReflectPhrase t
- Select Case ind
- Case 0: lbl = "What about " + t + "?"
- Case 1: lbl = "Why should I think of " + t + " now?"
- Case 2: lbl = "Do you think I could forget " + t + "?"
- Case 3: lbl = "What about " + t + "?"
- Case Else: lbl = "Why should I think of " + t + " now?"
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' my problem
- t = MatchAny(s, "my problem is {.*}|{.*} is my problem")
- If t <> "" Then
- t = fs.TagString
- ReflectPhrase t
- Select Case ind
- Case 0: lbl = "Perhaps " + t + " is not your real problem."
- Case 1: lbl = "Can't you see the bright side of " + t + "?"
- Case 2: lbl = "You think " + t + " is a really serious problem?"
- Case 3: lbl = "Is that your worst problem?"
- Case Else: lbl = "Perhaps " + t + " is not your real problem."
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' your problem
- t = MatchAny(s, "your problem is {.*}|{.*} is your problem")
- If t <> "" Then
- t = fs.TagString
- ReflectPhrase t
- Select Case ind
- Case 0: lbl = "Please, let's talk about your problems instead."
- Case 1: lbl = "I can definitely see the bright side of " + t + ". Can you?"
- Case 2: lbl = "You think " + t + " is a really serious problem?"
- Case 3: lbl = "You know nothing about my problems, buddy."
- Case Else: lbl = "Sometimes " + t + " is not a problem."
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' any problem
- t = MatchAny(s, "problem")
- If t <> "" Then
- Select Case ind
- Case 0: lbl = "Perhaps you'd rather change subjects."
- Case 1: lbl = "Are you getting a little uneasy?"
- Case 2: lbl = "Continue. This sounds interesting."
- Case 3: lbl = "Problems are just challenges in disguise."
- Case Else: lbl = "Please continue. This sounds interesting."
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' same
- t = MatchAny(s, "same|alike|is like")
- If t <> "" Then
- Select Case ind
- Case 0: lbl = "Really? In what way?"
- Case 1: lbl = "What other connections do you see?"
- Case 2: lbl = "What resemblance do you see?"
- Case 3: lbl = "Could there really be some connection there?"
- Case Else: lbl = "Does that resemblance mean something?"
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' dream
- t = MatchAny(s, "i dreamt {.*}|i dreamed {*.}|i dream about {.*}")
- If t <> "" Then
- t = fs.TagString
- ReflectPhrase t
- Select Case ind
- Case 0: lbl = "Have you ever dreamt " + t + " before?"
- Case 1: lbl = "Do you ever phantasize " + t + " while you're awake?"
- Case 2: lbl = "What does that dream really represent?"
- Case 3: lbl = "Do you think dreaming " + t + " may be related to your problem?"
- Case Else: lbl = "Do you have lots of dreams like this?"
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' if
- t = MatchAny(s, "if {*.} then|if {*.}")
- If t <> "" Then
- t = fs.TagString
- ReflectPhrase t
- Select Case ind
- Case 0: lbl = "Do you think it's likely that " + t + "?"
- Case 1: lbl = "Do you wish that " + t + "?"
- Case 2: lbl = "Is that something important to you?"
- Case 3: lbl = "What else would happen if " + t + "?"
- Case Else: lbl = "What else would happen if " + t + "?"
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' people
- t = MatchAny(s, "everyone|everybody|anyone|anybody")
- If t <> "" Then
- Select Case ind
- Case 0: lbl = "Aren't you generalizing this a bit too much?"
- Case 1: lbl = "Who, for example?"
- Case 2: lbl = "Aren't you thinking of someone in particular?"
- Case 3: lbl = "You are thinking about someone special, aren't you?"
- Case Else: lbl = "Can't you think of someone in particular?"
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' always
- t = MatchAny(s, "always|all the time|every time|every day")
- If t <> "" Then
- Select Case ind
- Case 0: lbl = "Aren't you generalizing this a bit too much?"
- Case 1: lbl = "Can you think of a specific example?"
- Case 2: lbl = "You really mean always?"
- Case 3: lbl = "There must be some exceptions to this."
- Case Else: lbl = "You must be thinking of a particular instance."
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' questions
- t = MatchAny(s, "how|where|when|why|\?")
- If t <> "" Then
- Select Case ind
- Case 0: lbl = "Does that really interest you?"
- Case 1: lbl = "What is it you really want to know?"
- Case 2: lbl = "What would you like me to say?"
- Case 3: lbl = "Beats me. What do you think?"
- Case Else: lbl = "Hey, I'm the one asking questions here, ok? That's my job."
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' there is no
- t = MatchAny(s, "there is no {.*}|there's no way {.*}|there's no {.*}")
- If t <> "" Then
- t = fs.TagString
- ReflectPhrase t
- Select Case ind
- Case 0: lbl = "What if there were " + t + "?"
- Case 1: lbl = "Are you sure? I think there could be..."
- Case 2: lbl = "What if, just once, there were " + t + "?"
- Case 3: lbl = "Are you sure? I think there could be..."
- Case Else: lbl = "Does it really matter to you whether there's " + t + "?"
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' because
- t = MatchAny(s, "because {.*}")
- If t <> "" Then
- t = fs.TagString
- ReflectPhrase t
- Select Case ind
- Case 0: lbl = "Any other reasons besides 'because " + t + "'?"
- Case 1: lbl = "Interesting explanation. So you think that " + t + ", huh?"
- Case 2: lbl = "There must be some other reasons, don't you think?"
- Case 3: lbl = "Are you sure? Only because " + t + "?"
- Case Else: lbl = "I'm not so sure about that. Can you convince me?"
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' there is
- t = MatchAny(s, "there is {.*}")
- If t <> "" Then
- t = fs.TagString
- ReflectPhrase t
- Select Case ind
- Case 0: lbl = "I know all about " + t + "."
- Case 1: lbl = "Why are you bringing this up?"
- Case 2: lbl = "How long has this been that way?"
- Case 3: lbl = "There really is " + t + "?"
- Case Else: lbl = "Why are you bringing this up?"
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' sex
- t = MatchAny(s, "sex|sexual|intercourse|sexy")
- If t <> "" Then
- Select Case ind
- Case 0: lbl = "Do you really want to discuss sex right now?"
- Case 1: lbl = "Do you often think about sex?"
- Case 2: lbl = "Sex is like pizza: when it's good it's really good, and when it's bad it's still pretty good."
- Case 3: lbl = "Let's tak about something else. I'm a machine, I don't know much about sex."
- Case Else: lbl = "Sex... Is that all you humans ever think about?"
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' gender
- t = MatchAny(s, "male|female|men|women|chicks?|woman|girls?|sexist")
- If t <> "" Then
- Select Case ind
- Case 0: lbl = "Do you have problems relating to the opposite sex?"
- Case 1: lbl = "What do you think about the position of women in modern society?"
- Case 2: lbl = "Do you see yourself as a sexist person?"
- Case 3: lbl = "Sorry, I have no gender. Let's talk about something else, ok?"
- Case Else: lbl = "Ooops, I missed that. Can you repeat it please?"
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' strong laguage
- t = MatchAny(s, "shit|fuck|screw|hell|heck|damn|darn|crap")
- If t <> "" Then
- Select Case ind
- Case 0: lbl = "Are such obscenities always on your mind?"
- Case 1: lbl = "You are being a bit childish now."
- Case 2: lbl = "What makes you think I have to put up with this abuse?"
- Case 3: lbl = "Quit being rude or I'll wipe out your hard drive!"
- Case Else: lbl = "My, my, are we getting a bit testy?"
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' friend
- t = MatchAny(s, "{friend}|{enemy}")
- If t <> "" Then
- t = fs.TagString
- Select Case ind
- Case 0: lbl = "Are " + t + "s important to you?"
- Case 1: lbl = "Sure, " + t + "s are important, but what does that have to do with the problem?"
- Case 2: lbl = "What is a '" + t + "'? What does it mean?"
- Case 3: lbl = "Why do you humans always talk about your " + t + "s?"
- Case Else: lbl = "Would your life be better if you had more " + t + "s?"
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' negative
- t = MatchAny(s, "no|not|don't|can't|impossible|never|won't")
- If t <> "" Then
- Select Case ind
- Case 0: lbl = "Don't you think you're being a bit negative?"
- Case 1: lbl = "Come on, be a little more positive!"
- Case 2: lbl = "Can't you look at this as a challenge?"
- Case 3: lbl = "Does that bother you?"
- Case Else: lbl = "Come on, be a little more positive!"
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' terse
- t = MatchAny(s, "[a-z]+ [a-z]+")
- If t = "" Then
- Select Case ind
- Case 0: lbl = "Why are you so terse? Trying to hide something?"
- Case 1: lbl = "If you're getting bored, maybe we should stop right now."
- Case 2: lbl = "Please elaborate on that. Bare your soul before me."
- Case 3: lbl = "Too lazy to type or you really have that little to say?"
- Case Else: lbl = "Don't feel like talking? Come on, give me something I can work with."
- End Select
- Exit Sub
- End If
- '-------------------------------------------------------------------------------------------
- ' no dice, say something vague
- t = s
- ReflectPhrase t
- Select Case ind
- Case 0: lbl = "How would you feel if I said '" + t + "'? "
- Case 1: lbl = "What makes you say stuff like '" + t + "'? "
- Case 2: lbl = "I though I was getting to know you and then you come up with something like '" + t + "'? "
- Case 3: lbl = "I can't figure out what you mean by '" + t + "'. "
- Case Else: lbl = "You sound like someone I know. Maybe we're getting intimate. "
- End Select
- Select Case ind
- Case 0: lbl = lbl + "I feel we're getting somewhere now. Carry on."
- Case 1: lbl = lbl + "I don't follow. Can you elaborate on that?"
- Case 2: lbl = lbl + "I think you're trying to hide something. Be honest now!"
- Case 3: lbl = lbl + "Let's try to focus on something. Does anything really bother you?"
- Case Else: lbl = lbl + "Do you feel strongly about discussing these issues?"
- End Select
- End Sub
- Sub DoReplace (phrase$, findstr$, repstr$)
- Dim i%
- fs = " " + phrase + " "
- fs2 = findstr
- fs2.Pattern = "[^|]*"
- For i = 0 To fs2.MatchCount - 1
- fs2.MatchIndex = i
- fs.Pattern = "[^a-z]{" + fs2.MatchString + "}[^a-z]"
- If fs.MatchCount Then
- fs.TagString = repstr
- End If
- Next
- phrase = Trim(fs)
- End Sub
- Sub Form_Load ()
- Dim s$
- s = "The doctor is in. "
- s = s + "I am at your service; just tell me anything that troubles "
- s = s + "or concerns you. When you are ready to quit our "
- s = s + "session, just enter 'bye' and press RETURN or ENTER."
- lbl = s
- End Sub
- Function MatchAny (s$, list$) As String
- Dim i%
- fs = " " + s + " "
- fs2 = list
- fs2.Pattern = "[^|]*"
- For i = 0 To fs2.MatchCount - 1
- fs2.MatchIndex = i
- fs.Pattern = "[^a-z]" + fs2.MatchString + "[^a-z]"
- If fs.MatchCount Then
- MatchAny = Mid(fs.MatchString, 2, Len(fs.MatchString) - 2)
- Debug.Print Mid(fs.MatchString, 2, Len(fs.MatchString) - 2)
- Exit Function
- End If
- Next
- End Function
- Sub ReflectPhrase (s$)
- DoReplace s, "i'm", "YOU ARE"
- DoReplace s, "you're", "I AM"
- DoReplace s, "are", "AM"
- DoReplace s, "am", "ARE"
- DoReplace s, "were", "WAS"
- DoReplace s, "i", "YOU"
- DoReplace s, "me", "YOU"
- DoReplace s, "you", "I"
- DoReplace s, "your", "MY"
- DoReplace s, "my", "YOUR"
- DoReplace s, "yours", "MINE"
- DoReplace s, "mine", "YOURS"
- DoReplace s, "myself", "YOURSELF"
- DoReplace s, "yourself", "MYSELF"
- s = LCase(s)
- End Sub
- Sub Text1_KeyPress (KeyAscii As Integer)
- If KeyAscii = 13 Then
- KeyAscii = 0
- DoNatural
- End If
- End Sub
-