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: source/ch3_javadatatypes.ptx
+13-8Lines changed: 13 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -830,11 +830,11 @@ public class HistoArray {
830
830
</p>
831
831
832
832
<p>
833
-
Lets stay with a simple frequency counting example, only this time we will count the frequency of words in a document. A simple Python program for this job could look like this:
833
+
Lets stay with a simple frequency counting example, only this time we will count the frequency of words in a document. <xrefref="python-word-count"text="type-global"/> shows a simple Python program for how this could look.
""" Program to read a file and count the frequency of words in the file. """
@@ -850,11 +850,14 @@ def main():
850
850
main()
851
851
</code> <tests> </tests>
852
852
</program>
853
+
</listing>
853
854
854
855
<p>
855
-
This program reads the file <c>alice30.txt</c> (which follows), and it then splits it into a list of words. Next it creates a dictionary called <c>count</c> which maps each word to the number of times that word occurs in the text. Finally, it prints out the words in alphabetical order along with their frequency.
856
+
This program reads the file <c>alice30.txt</c> in <xrefref="datafile-alice1"text="type-global"/>, and it then splits it into a list of words. Next it creates a dictionary called <c>count</c> which maps each word to the number of times that word occurs in the text. Finally, it prints out the words in alphabetical order along with their frequency.
856
857
</p>
857
858
859
+
<dataxml:id="datafile-alice1">
860
+
<title>Data file for testing the word frequency program</title>
0 commit comments