diff --git a/text.ipynb b/text.ipynb index f1c61e175..aeebf8ecd 100644 --- a/text.ipynb +++ b/text.ipynb @@ -18,7 +18,8 @@ "outputs": [], "source": [ "from text import *\n", - "from utils import open_data" + "from utils import open_data\n", + "from notebook import psource" ] }, { @@ -55,46 +56,11 @@ }, { "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "%psource UnigramWordModel" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "%psource NgramWordModel" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "%psource UnigramCharModel" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": true - }, + "execution_count": null, + "metadata": {}, "outputs": [], "source": [ - "%psource NgramCharModel" + "psource(UnigramWordModel, NgramWordModel, UnigramCharModel, NgramCharModel)" ] }, { @@ -117,7 +83,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -156,18 +122,18 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Conditional Probabilities Table: {'myself': 1, 'to': 2, 'at': 2, 'pleased': 1, 'considered': 1, 'will': 1, 'intoxicated': 1, 'glad': 1, 'certain': 2, 'in': 2, 'now': 2, 'sitting': 1, 'unusually': 1, 'approaching': 1, 'by': 1, 'covered': 1, 'standing': 1, 'allowed': 1, 'surprised': 1, 'keenly': 1, 'afraid': 1, 'once': 2, 'crushed': 1, 'not': 4, 'rapt': 1, 'simulating': 1, 'rapidly': 1, 'quite': 1, 'describing': 1, 'wearied': 1} \n", + "Conditional Probabilities Table: {'now': 2, 'glad': 1, 'keenly': 1, 'considered': 1, 'once': 2, 'not': 4, 'in': 2, 'by': 1, 'simulating': 1, 'intoxicated': 1, 'wearied': 1, 'quite': 1, 'certain': 2, 'sitting': 1, 'to': 2, 'rapidly': 1, 'will': 1, 'describing': 1, 'allowed': 1, 'at': 2, 'afraid': 1, 'covered': 1, 'approaching': 1, 'standing': 1, 'myself': 1, 'surprised': 1, 'unusually': 1, 'rapt': 1, 'pleased': 1, 'crushed': 1} \n", "\n", "Conditional Probability of 'once' give 'i was': 0.05128205128205128 \n", "\n", - "Next word after 'i was': not\n" + "Next word after 'i was': wearied\n" ] } ], @@ -198,7 +164,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -246,16 +212,16 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "not it of before most regions multitudes the a three\n", - "the inhabitants of so also refers to the cube with\n", - "the service of education waxed daily more numerous than the\n" + "hearing as inside is confined to conduct by the duties\n", + "all and of voice being in a day of the\n", + "party they are stirred to mutual warfare and perish by\n" ] } ], @@ -283,23 +249,22 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "it again stealing away through the ranks of his nephew but he laughed most immoderately\n", - "exclaiming that he henceforth exchanged them for the artist s pencil how great and glorious\n", - "compound now for nothing worse but however all that is quite out of the question\n", - "accordance with precedent and for the sake of secrecy he must condemn him to perpetual\n" + "leave them at cleveland this christmas now pray do not ask you to relate or\n", + "meaning and both of us sprang forward in the direction and no sooner had they\n", + "palmer though very unwilling to go as well from real humanity and good nature as\n", + "time about what they should do and they agreed he should take orders directly and\n" ] } ], "source": [ "data = open_data(\"EN-text/flatland.txt\").read()\n", - "data += open_data(\"EN-text/gutenberg.txt\").read()\n", "data += open_data(\"EN-text/sense.txt\").read()\n", "\n", "wordseq = words(data)\n", @@ -344,13 +309,11 @@ }, { "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": true - }, + "execution_count": null, + "metadata": {}, "outputs": [], "source": [ - "%psource viterbi_segment" + "psource(viterbi_segment)" ] }, { @@ -373,7 +336,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -388,7 +351,7 @@ "source": [ "flatland = open_data(\"EN-text/flatland.txt\").read()\n", "wordseq = words(flatland)\n", - "P = UnigramTextModel(wordseq)\n", + "P = UnigramWordModel(wordseq)\n", "text = \"itiseasytoreadwordswithoutspaces\"\n", "\n", "s, p = viterbi_segment(text,P)\n", @@ -447,7 +410,7 @@ }, "outputs": [], "source": [ - "%psource IRSystem" + "psource(IRSystem)" ] }, { @@ -490,7 +453,7 @@ }, "outputs": [], "source": [ - "%psource UnixConsultant" + "psource(UnixConsultant)" ] }, { @@ -504,7 +467,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -533,7 +496,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -628,7 +591,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -656,7 +619,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -748,13 +711,11 @@ }, { "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": true - }, + "execution_count": null, + "metadata": {}, "outputs": [], "source": [ - "%psource PermutationDecoder" + "psource(PermutationDecoder)" ] }, { @@ -811,7 +772,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.2+" + "version": "3.5.3" } }, "nbformat": 4, pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy