Starter Code
Get the starter code on GitHub Classroom
Docker
There’s a docker image available for this course. See the course docker instructions for details about how to work on your own machine.
RegEx Practice
Practice regular expressions by playing RegEx Golf.
You must complete the following:
- Warmup
- Anchors
- It never ends
- Ranges
- Backrefs
- One additional puzzle of your choosing
Turn In
In the file golf.py, fill in your best regular expression for each of the puzzles that you solved. (autograded, 14 points)
Integrity Note
Since these puzzles are online, there are (undoubtedly) solutions posted somewhere. I trust you not to look for those solutions, but to submit the best solutions you can come up with on your own.
SlackBot
We’ll use Slack for communicating with each other this semester. There are already channels set up on our Slack Workspace for each of the assignments, and you should feel free to create your own channels for communicating with your teammates.
Stop now and make sure that you have access to the CS159 Slack Workspace.
For this part of lab, you will make an ELIZA-like chatbot that can join our slack workspace. You will follow these steps:
-
Follow the instructions on this page to create a Slack App in the CS159 Workspace. You can name your bot whatever you like. Stop when you get to the page with your Bot User OAuth Access Token.
- Create a Slack App in the CS159 Workspace:
- Go to https://api.slack.com/apps?new_classic_app=1 and create an app. You can name it anything you want.
- Go to the “App Home” tab and follow the “Add A Legacy Bot User” link. Set up your Bot, choosing any name you would like for it.
- Click “OAuth & Permissions” and “Install to Workspace.”
- Copy the Bot User OAuth Access Token.
-
Open the file
slackbot.pyand paste in your access token. - Start your bot by running
python3 slackbot.py. To see the bot in the Slack app, search for its name (on a mac, command+K opens the search bar). Send a message to your bot in slack, and confirm that it replies.
Once you have those steps working, you’re ready to improve upon your bot.
The only requirement I have is that you must modify the make_message function in slackbot.py to respond to messages from slack users. Your function must make use of regular expressions using the python re library. In particular, you should use each of the following at least once (autograded, 2 points):
- Regular expression groups (
(...)) - Character classes (
[...],\d,\D,\w,\W,\s,\S, etc.) - Regular expression qualtifiers (
+,*, and/or{...})
You can choose the domain and personality of your both. It can be a Rogerian psychologist like ELIZA, or you can choose a different domain. If you choose a different domain, make sure it’s one where you can reasonably use a lot of repitition from regular expressions.
You should also update the name and emoji image of your chat bot. In Slack, if you click the icon to add an emoji to a message and then hover over the different emoji choices, it will tell you want the text alias for each emoji is. My demo bot uses the :dog: emoji.
Turn In
On Gradescope, you should submit your completed slackbot.py file with your implementation.
You should also submit a .pdf report that describes your Bot. That report should have the following sections:
- Overview: An introduction to your SlackBot. What domain does it work in? What is its personality? (5 points for completeness and clarity)
- Regex Description: Clearly describe how you make use of each of the required regular expression features in your
make_messagefunction. (5 points for completeness and clarity) - Analysis: Describe at least one interaction with your bot that worked well. You should include a screenshot of your discussion inside of Slack. Additionally, describe at least one interaction with your bot that is problematic. Thoughtfully describe how you would address the existing shortcomings of your Bot if you had more time. For example, what would you do to make your bot better if you had another week to work on it? If you were going to use this code as the starting point for a final class project? (20 points for completeness and clarity)
The starter code has a Markdown file that you can use to write your analysis. To turn your markdown into a .pdf file, use pandoc:
pandoc analysis.md -o analysis.pdf
Please add your analysis.pdf file to your GitHub repository so that we can view it for grading.