CSc 250 - Digital Assistant

Digital Assistants

Many of us have used a digital assistant before (ranging from Google Assistant, Apple’s Siri, Amazon’s Alexa, Microsoft’s Cortana, and perhaps more). In this assignment, you will be creating a very simplistic version of a digital assistant such as these.

The digital assistant (DA) that you create will be MUCH simpler. The interface for using it will not be with your voice - rather, it will be with typed text on the python console. Also, it will only be able to recognize to main types of commands. You can either tell the DA something that you want it to remember, or you can ask the DA to recall something that you told it.

Tell the DA something

The first type of command (telling) will be a single sentence with the following form:

(entity) (category) (was / is / will be) (item)

There are four parts to this command.

Below are a few examples of full commands:

You program will need to extract the four components of each command that is entered, and save them in parallel lists. In order to separate the components, you may want to use the split() function, as well as other advanced string features of python.

Any time the DA requests a command / sentence from the user, the line should begin with USER: .

Ask the DA something

You can also ask the DA for information that you have previously told it. These requests will take the following form:

what (tense) (entity) (category)?

These ask commands will always begin with the word what. The tense, entity, and category should match up with what you previously saved / remembered. Again, you’ll want to use the string split() function along with other string functionality to extract the components of the command. You should use the strip() function to ignore the question-mark.

DA Replies

Any time the DA replies-to a command / sentence from the user, the line should begin with DA: followed by the message. When DA accepts new information, it should reply with DA: OK!. When the user asks the DA a question, the DA will reply with the expected information, or an error message. See the examples below for what the replies should look like.

There is also a special-case for the DA replies. If the user refers to “my”, the DA will switch it to “your” in the reply. Also, “your” should be switched to “my”. This is shown in one of the examples below.

Guided Example(s)

Let’s say that the user entered

USER: joe's favorite food is orange chicken

Your program should remember that the entity my told the program that their favorite food is (present tense) orange chicken. Later, the user could say:

USER: what is joe's favorite food?

And the program should reply with:

DA: joe's favorite food is orange chicken.

If in the same program session, we were to then enter:

USER: joe's favorite food was pizza
DA: OK!
USER: joe's favorite food is salad
DA: OK!
USER: joe's favorite food will be pasta
DA: OK!

Then the following would be the program’s response:

USER: what is joe's favorite food?
DA: joe's favorite food is orange chicken
USER: what was joe's favorite food?
DA: joe's favorite food was pizza
USER: what will be joe's favorite food?
DA: joe's favorite food will be pasta

Notice in this example that: (A) the software remembers a different food for the same person, for each of the three tenses, and (B) the old “orange chicken” favorite was overwritten by the new “salad” preference for the present-tense (is) case.

Submission

Submit this to D2L by Friday, March 2nd, by 5:00pm. Name the file digital_assistant.py.

Complete Examples

DA: Hi there, let's talk. . .
USER: my favorite food is orange chicken
DA: OK!
USER: what is my favorite food?
DA: your favorite food is orange chicken
USER: james's hardest course is CS 500
DA: OK!
USER: what is james's hardest course?
DA: james's hardest course is CS 500
USER: bye
DA: bye!
DA: Hi there, let's talk. . .
USER: lance's largest pet is a dog
DA: OK!
USER: lance's largest pet was a cat
DA: OK!
USER: lance's largest pet will be a horse
DA: OK!
USER: what was lances largest pet?
DA: lance's largest pet was a cat
USER: what will be lances largest pet?
DA: lance's largest pet will be a horse
USER: what is lances largest pet?
DA: lance's largest pet is a dog
USER: bye
DA: bye!
DA: Hi there, let's talk. . .
USER: my first car was a dodge durango
DA: OK!
USER: your first car was nothing!
DA: OK!
USER: what was my first car?
DA: my first car was nothing!
USER: what was your first car?
DA: my first car was nothing!
USER: bye
DA: bye!
DA: Hi there, let's talk. . .
USER: his name is joe
DA: OK!
USER: his favorite food is pizza
DA: OK!
USER: his job will be a programmer
DA: OK!
USER: what is his name?
DA: his name is joe
USER: what is his favorite food?
DA: his favorite food is pizza
USER: what will be his job?
DA: his job will be a programmer
USER: his favorite food is salad
DA: OK!
USER: his job will be a professor of research
DA: OK!
USER: what will be his job?
DA: his job will be a professor of research
USER: what is his favorite food?
DA: his favorite food is salad
USER: bye
DA: bye!