arrow-left

All pages
gitbookPowered by GitBook
1 of 3

Loading...

Loading...

Loading...

0.2. Quiz

Quiz 0: Getting Started

hashtag
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 package under the src package.

3. Create a python file called under the quiz package and copy the code:

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:

hashtag
Submission

1. Create the 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).

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.

Press the [Commit and Push] button.

quizarrow-up-right
quiz0.pyarrow-up-right
.gitignorearrow-up-right
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()
S: Hello. How are you?
U: I'm good
S: Glad to hear that you are doing well :)
U: Thanks
S: See you later!
==========================================
S: Hello. How are you?
U: It's not going well
S: I hope your day gets better soon :(
U: Hopefully
S: Take care!
.idea/
venv/

0. Getting Started

This chapter helps you set up the development environment for this course.

hashtag
Content

  1. Environment Setup

Quiz

0.1. Environment Setup

Setup a Python programming environment with GitHub and PyCharm.

hashtag
Python

  • Install Python 3.11.xarrow-up-right.

  • Lower versions of Python may not be compatible with this course.

hashtag
GitHub

  1. Login to (create an account if you do not have one).

  2. Create a new repository called conversational-ai and make it private.

  3. From the [Settings]

hashtag
PyCharm

Install on your local machine:

  • The following instructions assume that you have "PyCharm 2022.3.x Professional Edition".

  • You can get the professional version by applying for an .

Configure your GitHub account:

  1. Go to [Preferences] - [Version Control] - [GitHub].

  2. Press [+], select Log in via GitHub, and follow the procedure.

Create a new project:

  1. Press the [Get from VCS] button on the Welcome prompt.

  2. Choose [GitHub] on the left menu, select the conversational-ai repository, and press [Clone] (make sure the directory name is conversational-ai).

Setup an interpreter:

  1. Go to [Preferences] - [Project: conversational-ai] - [Project Interpreter].

  2. Click Add Interpreter and select Add Local Interpreter.

Install packages:

  1. Open a terminal by clicking [Terminal] at the bottom (or go to [View] - [Terminal]).

  2. Upgrade (if necessary) by entering the following command into the terminal:

  3. Install the

menu, add the instructors as collaborators of this repository.
  • Jinho Choi: jdchoi77arrow-up-right

  • Talyn Fan: talynfanarrow-up-right

  • Benjamin Ascoli: bossbenarrow-up-right

  • Sichang Tu:

In the prompted window, choose [Virtualenv Environment] on the left menu, configure as follows, then press [OK]:
  • Environment: New

  • Location: LOCAL_PATH/conversational-ai/venv

  • Base interpreter: Python 3.11

(STDM) with the following command:
  • If the terminal prompts "Successfully installed ...", the packages are installed on your machine.

  • GitHubarrow-up-right
    PyCharmarrow-up-right
    academic licensearrow-up-right
    piparrow-up-right
    Emora State Transition Dialogue Managerarrow-up-right
    python -m pip install --upgrade pip
    pip install emora_stdm
    SichangTuarrow-up-right