This program, wordgraph, will read a text file, count word occurrences and produce a histogram of the results.
- Java JDK 5+ download here
- Maven 2+ download here
This lab is about Functional Programming in Java, using mainly Google Guava. The purpose is to build a little utility that shows a histogram graph of the number of occurrences of each word in a text file. Like this:
% java ...WordGraph "mary.txt"
fleece #
but #
...
lamb ############
mary #############
the ##############
In the process, you will learn about map, filter and reduce, or as they are called in Google Guava: transform, filter, and ... well, there is no reduce in Google Guava. There is no parallel transform either. Let's implement those first, before we get into the wordgraph business.
Check out this lab from github.com:
git clone git://github.com/ulsa/javawordgraph.git
Change to the lab directory:
cd javawordgraph
The lab is constructed using maven-lab-plugin. Initialize the lab to step 0 by running:
mvn lab:init
Move to the next step when you have solved the problem, compiled the code and ran the tests, or if otherwise instructed to move on. You can see solutions up to the current step in src/solution/java. To move to the next step, do this:
mvn lab:next
Other useful commands:
mvn lab:currentStep
mvn lab:reset
mvn lab:setStep -DlabStep=n
Your workflow should be the following:
- See INSTRUCTIONS.txt for instructions
- Compile and run test cases to see what you need to do
- (if necessary) Check HINTS.txt file for hints.
- (if necessary) Check src/solution/java for a solution.
- Once the tests run successfully, mvn lab:next to get the next step
Notice: You will need to create classes and methods to fix compilation errors! Make sure to create files in src/main/java!
Good luck!