From d56ce4061b99081a27da8ff31a797470e51bcd81 Mon Sep 17 00:00:00 2001 From: Nick LaLone Date: Tue, 24 Jul 2018 14:00:11 -0500 Subject: [PATCH] ad --- Lectures/Week-13-XPath-B.ipynb | 188 ++++++++++++++++----------------- Lectures/stagedirections.csv | 32 ++++++ 2 files changed, 126 insertions(+), 94 deletions(-) diff --git a/Lectures/Week-13-XPath-B.ipynb b/Lectures/Week-13-XPath-B.ipynb index 9f9ff59..260d281 100644 --- a/Lectures/Week-13-XPath-B.ipynb +++ b/Lectures/Week-13-XPath-B.ipynb @@ -102,7 +102,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 62, "metadata": {}, "outputs": [], "source": [ @@ -142,7 +142,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 63, "metadata": {}, "outputs": [], "source": [ @@ -177,7 +177,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 64, "metadata": {}, "outputs": [ { @@ -217,7 +217,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 65, "metadata": {}, "outputs": [ { @@ -244,7 +244,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 66, "metadata": {}, "outputs": [ { @@ -268,7 +268,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 67, "metadata": {}, "outputs": [ { @@ -352,7 +352,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 68, "metadata": {}, "outputs": [ { @@ -379,7 +379,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 69, "metadata": {}, "outputs": [ { @@ -426,7 +426,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 70, "metadata": {}, "outputs": [], "source": [ @@ -435,7 +435,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 71, "metadata": {}, "outputs": [], "source": [ @@ -444,7 +444,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 72, "metadata": {}, "outputs": [ { @@ -480,7 +480,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 73, "metadata": {}, "outputs": [], "source": [ @@ -489,45 +489,45 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 74, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "[,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ]" + "[,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ,\n", + " ]" ] }, - "execution_count": 13, + "execution_count": 74, "metadata": {}, "output_type": "execute_result" } @@ -549,43 +549,43 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 75, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n" + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" ] } ], @@ -613,7 +613,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 76, "metadata": {}, "outputs": [ { @@ -660,7 +660,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 77, "metadata": {}, "outputs": [ { @@ -716,7 +716,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 78, "metadata": {}, "outputs": [ { @@ -803,7 +803,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 79, "metadata": {}, "outputs": [ { @@ -872,7 +872,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 80, "metadata": {}, "outputs": [ { @@ -902,7 +902,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 81, "metadata": {}, "outputs": [], "source": [ @@ -920,7 +920,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 82, "metadata": {}, "outputs": [ { @@ -930,8 +930,8 @@ "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;31m# raises an error and halts the program if there are more than 1\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcheckFor1Result\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'too'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'many'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'MissingResult'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[1;32m\u001b[0m in \u001b[0;36mcheckFor1Result\u001b[1;34m(xpathresult, missing_value)\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mhowmany\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mxpathresult\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m raise ValueError(\"Your list had \" + str(howmany) + \" items instead of 1. Shutting down the program,\"\n\u001b[1;32m----> 5\u001b[1;33m + \"But here's your failed result: \" + str(xpathresult))\n\u001b[0m\u001b[0;32m 6\u001b[0m \u001b[1;32melif\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mxpathresult\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mxpathresult\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;31m# send the single result back when there's just 1\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;31m# raises an error and halts the program if there are more than 1\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcheckFor1Result\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'too'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'many'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'MissingResult'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;32m\u001b[0m in \u001b[0;36mcheckFor1Result\u001b[1;34m(xpathresult, missing_value)\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mhowmany\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mxpathresult\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m raise ValueError(\"Your list had \" + str(howmany) + \" items instead of 1. Shutting down the program,\"\n\u001b[1;32m----> 5\u001b[1;33m + \"But here's your failed result: \" + str(xpathresult))\n\u001b[0m\u001b[0;32m 6\u001b[0m \u001b[1;32melif\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mxpathresult\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mxpathresult\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;31m# send the single result back when there's just 1\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;31mValueError\u001b[0m: Your list had 2 items instead of 1. Shutting down the program,But here's your failed result: ['too', 'many']" ] } @@ -943,7 +943,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 83, "metadata": {}, "outputs": [ { @@ -961,7 +961,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 84, "metadata": {}, "outputs": [ { @@ -988,7 +988,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 85, "metadata": {}, "outputs": [], "source": [ @@ -997,7 +997,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 86, "metadata": {}, "outputs": [ { @@ -1033,8 +1033,8 @@ "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[0mresults\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcheckFor1Result\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mwho\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'MissingWho'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[0mresults\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcheckFor1Result\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdirtype\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'MissingType'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 8\u001b[1;33m \u001b[0mresults\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\" \"\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcheckFor1Result\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdirtext\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'MissingText'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msplit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 9\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mresults\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;32m\u001b[0m in \u001b[0;36mcheckFor1Result\u001b[1;34m(xpathresult, missing_value)\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mhowmany\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mxpathresult\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m raise ValueError(\"Your list had \" + str(howmany) + \" items instead of 1. Shutting down the program,\"\n\u001b[1;32m----> 5\u001b[1;33m + \"But here's your failed result: \" + str(xpathresult))\n\u001b[0m\u001b[0;32m 6\u001b[0m \u001b[1;32melif\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mxpathresult\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mxpathresult\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;31m# send the single result back when there's just 1\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[0mresults\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcheckFor1Result\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mwho\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'MissingWho'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[0mresults\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcheckFor1Result\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdirtype\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'MissingType'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 8\u001b[1;33m \u001b[0mresults\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\" \"\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcheckFor1Result\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdirtext\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'MissingText'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msplit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 9\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mresults\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m\u001b[0m in \u001b[0;36mcheckFor1Result\u001b[1;34m(xpathresult, missing_value)\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mhowmany\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mxpathresult\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m raise ValueError(\"Your list had \" + str(howmany) + \" items instead of 1. Shutting down the program,\"\n\u001b[1;32m----> 5\u001b[1;33m + \"But here's your failed result: \" + str(xpathresult))\n\u001b[0m\u001b[0;32m 6\u001b[0m \u001b[1;32melif\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mxpathresult\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mxpathresult\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;31m# send the single result back when there's just 1\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;31mValueError\u001b[0m: Your list had 7 items instead of 1. Shutting down the program,But here's your failed result: ['Enter ', '\\n ', 'Rosincrane', '\\n ', 'Rosincrance', '\\n ', '.']" ] } @@ -1060,7 +1060,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 87, "metadata": {}, "outputs": [ { @@ -1152,7 +1152,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 88, "metadata": {}, "outputs": [], "source": [ @@ -1171,7 +1171,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 89, "metadata": {}, "outputs": [], "source": [ @@ -1180,7 +1180,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 90, "metadata": {}, "outputs": [], "source": [ diff --git a/Lectures/stagedirections.csv b/Lectures/stagedirections.csv index e69de29..a3fc3d1 100644 --- a/Lectures/stagedirections.csv +++ b/Lectures/stagedirections.csv @@ -0,0 +1,32 @@ +speakerID,directionType,directionText +#F-ham-mar,entrance,Enter the Ghost. +#F-ham-hor,entrance,Enter Ghost againe. +#F-ham-mar,exit,Exit Ghost. +#F-ham-cla,entrance,Enter Voltemand and Cornelius. +#F-ham-cla,exit,Exit Voltemand and Cornelius. +#F-ham-lae,entrance,Enter Polonius. +#F-ham-hor #F-ham-mar,business,within. +#F-ham-pol,business,The Letter. +#F-ham-pol,exit,Exit King & Queen. +#F-ham-ham,entrance,Enter foure or fiue Players. +#F-ham-ham,exit,Exit Players. +#F-ham-ham,entrance,"Enter Polonius, Rosincrance, and Guildensterne." +#F-ham-ham,exit,Exit Polonius. +#F-ham-ger,business,Sleepes +#F-ham-ham,entrance,Enter Lucianus. +#F-ham-ham,entrance,Enter one with a Recorder. +#F-ham-ham,MissingType,within. +#F-ham-cla,entrance,Enter Ros. & Guild. +#F-ham-cla,exit,Exit Gent. +#F-ham-gmn,location,within. +#F-ham-cla,entrance,Enter Rosincrane Rosincrance . +#F-ham-cla,business,A noise within. +#F-ham-sai,business,Reads the Letter. +#F-ham-cla,entrance,Enter a Messenger. +#F-ham-cla,exit,Exit Messenger +#F-ham-clo.1,business,Sings. +#F-ham-clo.1,business,sings. +#F-ham-clo.1,business,sings. +#F-ham-ham,entrance,"Enter King, Queen, Laertes, and a Coffin, with Lords attendant." +#F-ham-lae,business,Leaps in the graue. +#F-ham-ham,business,"March afarre off, and shout within."