0.2. Quiz

Quiz 0: Getting Started

Task

1. Create a package called srcarrow-up-right under the conversational-ai directory.

circle-info

PyCharm may automatically create the __init__.py file under src, which is required for Python to treat the directory as a package, so leave the file as it is.

2. Create the quizarrow-up-right package under the src package.

3. Create a python file called quiz0.pyarrow-up-right under the quiz package and copy the code:

from emora_stdm import DialogueFlow

transitions = {
    'state': 'start',
    '`Hello. How are you?`': {
        '[{good, fantastic}]': {
            '`Glad to hear that you are doing well :)`': {
                'error': {
                    '`See you later!`': 'end'
                }
            }
        },
        'error': {
            '`I hope your day gets better soon :(`': {
                'error': {
                    '`Take care!`': 'end'
                }
            }
        }
    }
}

df = DialogueFlow('start', end_state='end')
df.load_transitions(transitions)

if __name__ == '__main__':
    df.run()
circle-info

If PyCharm prompts you to add quiz0.py to git, press [Add].

4. Run quiz0 by clicking [Run] - [Run 'quiz0']. An alternative way of running the program is to click the green triangle by the line #26 and select Run 'quiz0':

5. Conduct the following two dialogues with the chatbot you just created (S: system, U: user):

This is what your directory structure may look like in PyCharm after finishing this assignment:

Submission

1. Create the .gitignorearrow-up-right file under the conversational-ai directory and copy the content:

2. Add the following files to git by right-clicking on them and selecting [Git] - [Add]:

  • quiz0.py

  • .gitignore

circle-info

Once the files are added to git, they should turn green. If not, restart PyCharm and try to add them again.

3. Commit and push your changes to GitHub:

  • Right-click on conversational-ai.

  • Select [Git] - [Commit Directory].

  • Enter a commit message (e.g., Submit Quiz 0).

  • Press the [Commit and Push] button.

circle-info

Make sure you both commit and push, not just commit.

4. Check if the above files are properly pushed to your GitHub repository.

5. Submit the address of your repository to Canvas.

Last updated

Was this helpful?