Python Project: ELIZA

How ELIZA works?

It looks for simple patterns and substitutes to give the illusion of understanding from the computer (wiki).

Example

  • You write I need cake it can look for a pattern I need *
  • Then it can ask Why do you need cake?


This can be done simply as follows.

eliza_response = 'What do you need?'
while True:
    s = input(eliza_response + ' ')
    if 'I need ' in s:
        your_need = s.split('I need ')[-1]
        eliza_response = 'Why do you need ' + your_need + '?'
    elif 'because' in s:
        your_cause = s.split()[-1]
        eliza_response = 'Why are you ' + your_cause + '?'
    
        
    elif s == 'quit':
        break
    else:
        eliza_response = 'Can you tell me why?'

This can generate the following dialog.

What do you need? I need cake
Why do you need cake? because I am hungry
Why are you hungry? because it makes me less irritated
Why are you irritated? because I need to avoid low blood sugar
Why do you need to avoid low blood sugar? because I need a reward
Why do you need a reward? because I was good
Why are you good? because I need to learn Python
Why do you need to learn Python? because I need a job
Why do you need a job? quit

You can expand on this idea to make the conversation more real.

Learn Python

Learn Python A BEGINNERS GUIDE TO PYTHON

  • 70 pages to get you started on your journey to master Python.
  • How to install your setup with Anaconda.
  • Written description and introduction to all concepts.
  • Jupyter Notebooks prepared for 17 projects.

Python 101: A CRASH COURSE

  1. How to get started with this 8 hours Python 101: A CRASH COURSE.
  2. Best practices for learning Python.
  3. How to download the material to follow along and create projects.
  4. A chapter for each lesson with a descriptioncode snippets for easy reference, and links to a lesson video.

Expert Data Science Blueprint

Expert Data Science Blueprint

  • Master the Data Science Workflow for actionable data insights.
  • How to download the material to follow along and create projects.
  • A chapter to each lesson with a Description, Learning Objective, and link to the lesson video.

Machine Learning

Machine Learning – The Simple Path to Mastery

  • How to get started with Machine Learning.
  • How to download the material to follow along and make the projects.
  • One chapter for each lesson with a Description, Learning Objectives, and link to the lesson video.

Leave a Comment