diff --git a/sandbox.ld b/sandbox.ld new file mode 100644 index 0000000..be2a3d6 --- /dev/null +++ b/sandbox.ld @@ -0,0 +1,114 @@ +let input = "I remember my mother" + +print! ("DOCTOR") + +print! ("> ", input) + +let sanitized = do input > trim > downcase + +& ensuring we have spaces at the beginning and end +& this lets us match patterns as written below +let padded = join ([" ", sanitized, " "]) + +fn switch_persons { + ("i") -> "you" + ("you") -> "i" + ("am") -> "are" + ("me") -> "you" + ("my") -> "your" + (x) -> x +} + +fn repersonalize (x) -> do x > + trim > + split (_, " ") > + map (switch_persons, _) > + join (_, " ") + +let output = match padded with { + "{x} hello {y}" -> "How do you do. Please state your problem" + "{x} hi {y}" -> "How do you do. Please state your problem" + "{x} computer {y}" -> random ([ + "Do computers worry you" + "What do you think about machines" + "Why do you mention computers" + "What do you think machines have to do with your problem" + ]) + "{x} name {y}" -> "I am not interested in names" + "{x} sorry {y}" -> random ([ + "Please don't apologize" + "Apologies are not necessary" + "What feelings do you have when you apologize" + ]) + "{x} i remember {y}" -> { + let switched = repersonalize (y) + random ([ + "Do you often think of {switched}" + "Does thinking of {switched} bring anything else to mind" + "What else do you remember" + "Why do you recall {switched} right now" + "What in the present situation reminds you of {switched}" + "What is the connection between me and {switched}" + ]) + } + "{x} do you remember {y}" -> { + let switched = repersonalize (y) + random ([ + "Did you think I would forget {switched}" + "Why do you think I should recall {switched} now" + "What about {switched}" + "You mentioned {switched}" + ]) + } + "{x} if {y}" -> { + let switched = repersonalize (y) + random ([ + "Do you reall think that its likely that {switched}" + "Do you wish that {switched}" + "What do you think about {switched}" + "Really--if {switched}" + ]) + } + "{x} i dreamt {y}" -> { + let switched = repersonlize (y) + random ([ + "Really--{y}" + "Have you ever fantasized {y} while you were awake" + "Have you dreamt {y} before" + ]) + } + "{x} dream about {y}" -> { + let switched = repersonalize (y) + "How do you feel about {switched} in reality" + } + "{x} dream {y}" -> random ([ + "What does this dream suggest to you" + "Do you dream often" + "What persons appear in your dreams" + "Don't you believe that dream has to do with your problem" + ]) + "{x} my mother {y}" -> { + let switched = repersonalize (y) + random ([ + "Who else in your family {y}" + "Tell me more about your family" + ]) + } + "{x} my father {y}" -> random ([ + "Your father" + "Does he influence you strongly" + "What else comes to mind when you think of your father" + ]) + _ -> random ([ + "Very interesting" + "I am not sure I understand you fully" + "What does that suggest to you" + "Please continue" + "Go on" + "Do you feel strongly about discussing such things" + ]) +} + +print! (">>> ", upcase (output)) + +