MostCommonWordByChapter.java 693 Bytes
import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;

public class MostCommonWordByChapter {
    private static String BOOK_FILENAME = "data/alice.txt";

    public static void main(String[] args) throws FileNotFoundException {
                // chapter title
                                // word  freq
        HashMap<String, HashMap<String, Integer>> chapters = new HashMap<>();
        //chapter 1: "the cow goes moo"
        chapters.put("CHAPTER 1", new HashMap<>());
        HashMap<String, Integer> inner = chapters.get("CHAPTER 1");
        inner.put("moo", 1);
        // XXX: Next line is not necessary
        chapters.put("CHAPTER 1", inner);
    }
}