From c4fd0a750586fc59f2f7e0ea17237b9fdf8246e8 Mon Sep 17 00:00:00 2001 From: Habiba Sorour Date: Mon, 27 Jul 2026 22:01:20 +0300 Subject: [PATCH 1/2] added listing blocks --- source/ch3_javadatatypes.ptx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/source/ch3_javadatatypes.ptx b/source/ch3_javadatatypes.ptx index 199b13b..9944bde 100644 --- a/source/ch3_javadatatypes.ptx +++ b/source/ch3_javadatatypes.ptx @@ -829,8 +829,8 @@ public class HistoArray { 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:

- - + + def main(): data = open('alice30.txt') @@ -845,11 +845,14 @@ def main(): main() +

This program reads the file alice30.txt (which follows), and it then splits it into a list of words. Next it creates a dictionary called count 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.

+ + Data file for testing the word frequency program
 
             Down, down, down. Would the fall NEVER
@@ -872,12 +875,13 @@ main()
             nice grand words to say.)
             
+

Notice that the structure of the program is very similar to the numeric histogram program.

- - + + import java.util.Scanner; import java.util.ArrayList; @@ -915,6 +919,7 @@ public class HistoMap { } +

Improve the program above to remove the punctuation. From 1ff02cbe589cfcf9c1139c47f453ea98fd87e106 Mon Sep 17 00:00:00 2001 From: Habiba Sorour Date: Mon, 27 Jul 2026 22:48:33 +0300 Subject: [PATCH 2/2] added listing to text --- source/ch3_javadatatypes.ptx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/ch3_javadatatypes.ptx b/source/ch3_javadatatypes.ptx index 9944bde..d7187f6 100644 --- a/source/ch3_javadatatypes.ptx +++ b/source/ch3_javadatatypes.ptx @@ -826,7 +826,7 @@ public class HistoArray {

- 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: + Lets stay with a simple frequency counting example, only this time we will count the frequency of words in a document. shows a simple Python program for what this could look.

@@ -848,7 +848,7 @@ main()

- This program reads the file alice30.txt (which follows), and it then splits it into a list of words. Next it creates a dictionary called count 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. + This program reads the file alice30.txt in , and it then splits it into a list of words. Next it creates a dictionary called count 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.

@@ -877,7 +877,7 @@ main()

- Notice that the structure of the program is very similar to the numeric histogram program. + Notice that the structure of is very similar to the numeric histogram program.

@@ -922,7 +922,7 @@ public class HistoMap {

- Improve the program above to remove the punctuation. + Improve to remove the punctuation.