You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _sources/chap12.ipynb
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,7 @@
45
45
"source": [
46
46
"# Text Analysis and Generation\n",
47
47
"\n",
48
-
"At this point we have covered Python's core data structures -- lists, dictionaries, and tuples -- and and some algorithms that use them.\n",
48
+
"At this point we have covered Python's core data structures -- lists, dictionaries, and tuples -- and some algorithms that use them.\n",
49
49
"In this chapter, we'll use them to explore text analysis and Markov generation:\n",
50
50
"\n",
51
51
"* Text analysis is a way to describe the statistical relationships between the words in a document, like the probability that one word is followed by another, and\n",
<divclass="output text_plain highlight-myst-ansi notranslate"><divclass="highlight"><pre><span></span><enumerate at 0x7f114c127640>
1107
+
<divclass="output text_plain highlight-myst-ansi notranslate"><divclass="highlight"><pre><span></span><enumerate at 0x7f23a808afc0>
1108
1108
</pre></div>
1109
1109
</div>
1110
1110
</div>
@@ -1333,7 +1333,7 @@ <h2><span class="section-number">11.8. </span>Inverting a dictionary<a class="he
1333
1333
<p>Lists, dictionaries and tuples are <strong>data structures</strong>.
1334
1334
In this chapter we are starting to see compound data structures, like lists of tuples, or dictionaries that contain tuples as keys and lists as values.
1335
1335
Compound data structures are useful, but they are prone to errors caused when a data structure has the wrong type, size, or structure.
1336
-
For example, if a function expects a list if integers and you give it a plain old integer
1336
+
For example, if a function expects a list of integers and you give it a plain old integer
1337
1337
(not in a list), it probably won’t work.</p>
1338
1338
<p>To help debug these kinds of errors, I wrote a module called <codeclass="docutils literal notranslate"><spanclass="pre">structshape</span></code> that provides a function, also called <codeclass="docutils literal notranslate"><spanclass="pre">structshape</span></code>, that takes any kind of data structure as an argument and returns a string that summarizes its structure.
1339
1339
You can download it from
@@ -1495,7 +1495,7 @@ <h3><span class="section-number">11.11.2. </span>Exercise<a class="headerlink" h
<h1><spanclass="section-number">12. </span>Text Analysis and Generation<aclass="headerlink" href="#text-analysis-and-generation" title="Link to this heading">#</a></h1>
402
-
<p>At this point we have covered Python’s core data structures – lists, dictionaries, and tuples – and and some algorithms that use them.
402
+
<p>At this point we have covered Python’s core data structures – lists, dictionaries, and tuples – and some algorithms that use them.
403
403
In this chapter, we’ll use them to explore text analysis and Markov generation:</p>
404
404
<ulclass="simple">
405
405
<li><p>Text analysis is a way to describe the statistical relationships between the words in a document, like the probability that one word is followed by another, and</p></li>
Copy file name to clipboardExpand all lines: chap13.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -564,7 +564,7 @@ <h2><span class="section-number">13.2. </span>f-strings<a class="headerlink" hre
564
564
</div>
565
565
</div>
566
566
</div>
567
-
<p>To write this data to a file, you can use the <codeclass="docutils literal notranslate"><spanclass="pre">write</span></code> method, which we saw in <aclass="reference internal" href="chap08.html#section-writing-files"><spanclass="std std-ref">Chapter 8</span></a>.
567
+
<p>To write this data to a file, you can use the <codeclass="docutils literal notranslate"><spanclass="pre">write</span></code> method, which we saw in Chapter 8.
568
568
The argument of <codeclass="docutils literal notranslate"><spanclass="pre">write</span></code> has to be a string, so if we want to put other values in a file, we have to convert them to strings.
569
569
The easiest way to do that is with the built-in function <codeclass="docutils literal notranslate"><spanclass="pre">str</span></code>.</p>
Copy file name to clipboardExpand all lines: chap18.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1402,7 +1402,7 @@ <h2><span class="section-number">18.9. </span>Debugging<a class="headerlink" hre
1402
1402
</div>
1403
1403
</div>
1404
1404
<p><codeclass="docutils literal notranslate"><spanclass="pre">run_unittest</span></code> does not take <codeclass="docutils literal notranslate"><spanclass="pre">TestExample</span></code> as an argument – instead, it searches for classes that inherit from <codeclass="docutils literal notranslate"><spanclass="pre">TestCase</span></code>.
1405
-
Then is searches for methods that begin with <codeclass="docutils literal notranslate"><spanclass="pre">test</span></code> and runs them.
1405
+
Then it searches for methods that begin with <codeclass="docutils literal notranslate"><spanclass="pre">test</span></code> and runs them.
1406
1406
This process is called <strong>test discovery</strong>.</p>
1407
1407
<p>Here’s what happens when we call <codeclass="docutils literal notranslate"><spanclass="pre">run_unittest</span></code>.</p>
0 commit comments