{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Workbook for Chapter 10 of Explorations in Computing" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Section 10.2: Sentence Patterns" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### Important Note " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Make sure you read the note about ELIZA and IPython at the beginning of the Workbook for Section 10.1 and know how to terminate an ELIZA session running in an IPython Notebook." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### Execute this cell to initialize the notebook:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from PythonLabs.ElizaLab import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### Exercises " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "T10. Make a pattern that will apply to sentences that contain the word \"cow\":" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "T11. Try applying the pattern to see how this Pattern object will respond to sentences containing the word \"cow\":" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "T12. Add more sentences to the list of responses by calling `add_response`:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "T13. Now when you enter sentences that match the pattern the object will cycle through the responses. Type a few sentences with the word \"cow\":" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "T14. Make a new pattern that will apply to more than one word:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "T15. This new pattern should match any sentence that has one of the three words:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "T16. Call the `apply` method with sentence does not match the new pattern:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.4.2" } }, "nbformat": 4, "nbformat_minor": 0 }