Title: When I was 13 (many decades ago), I wrote the BASIC ELIZA that many of you have probably experienced (if you are of a certain age) or (if you are not ...) you&#x27;ve almost certainly experienced a knock-off of mine.<p>Today, Jan 8th, is the 100th centenary of Joseph Weizenbaum&#x27;s birth, so I asked ChatGPT to write ELIZA in js.<p>Long dialog (~10 rounds) short, here&#x27;s where it ended up:<p>&#x27;&#x27;&#x27;
&#x2F;&#x2F; A list of ELIZA&#x27;s responses
const responses = {
  &quot;I feel&quot;: [
    &quot;Why do you feel {0}?&quot;,
    &quot;What do you think is causing you to feel {0}?&quot;,
    &quot;Do you often feel {0}?&quot;,
    &quot;How do you normally deal with feeling {0}?&quot;
  ],
  &quot;I want&quot;: [
    &quot;Why do you want {0}?&quot;,
    &quot;What led you to want this?&quot;,
    &quot;Do you often find yourself wanting {0}?&quot;,
    &quot;How do you think getting what you want will make you feel?&quot;
  ],
  &quot;I need&quot;: [
    &quot;Why do you feel like you need {0}?&quot;,
    &quot;What led you to feel like you need this?&quot;,
    &quot;Do you often find yourself feeling like you need {0}?&quot;,
    &quot;How do you think getting what you need will make you feel?&quot;
  ]
};<p>&#x2F;&#x2F; A list of keywords
const keywords = Object.keys(responses);<p>&#x2F;&#x2F; A function that generates a response
function generateResponse(input) {
  &#x2F;&#x2F; Check if the input contains any of the keywords
  for (let i = 0; i &lt; keywords.length; i++) {
    if (input.includes(keywords[i])) {
      &#x2F;&#x2F; If the input contains a keyword, return a random response
      &#x2F;&#x2F; that includes the remainder of the input, with personal
      &#x2F;&#x2F; pronouns conjugated correctly
      const response = responses[keywords[i]][Math.floor(Math.random() * responses[keywords[i]].length)];
      return response.replace(&quot;{0}&quot;, input.substring(keywords[i].length + 1));
    }
  }
}<p>&#x2F;&#x2F; Test the function
console.log(generateResponse(&quot;I feel sad&quot;));
console.log(generateResponse(&quot;I want a new car&quot;));
console.log(generateResponse(&quot;I need some help&quot;));<p>&#x27;&#x27;&#x27;<p>My conclusion: It&#x27;s not yet up to being a 1970s 13 year old programmer....yet. :-)<p>----
(Apparently &#x27;&#x27;&#x27; ... &#x27;&#x27;&#x27; doesn&#x27;t do code in HN. Sorry for the wrap-around formatting.)
Upvote: