CSC220 Project Lab
Due: 10:59AM, Tuesday, November 2

The goal of this lab is to write an application that reads a text file, records for each word that appears in the file the line numbers in which they appear, and then given a set of words provides the list of all line numbers in which all of the words in the set appear.

Here is a sample program, LabHash.jar.

We use a Class StringAndNumbers for storing a string and a list of numbers in increasing order. The template for this class is given in StringAndNumbersInt.java. The methods required are as follows:

We use a class HashtableChain.java that implements the hash map interface KWHashMap.java. in keeping information about the word that has been encountered before. As discussed in the textbook and in class, KWHaspMap prescribes the way to record associations between an object in a generic class K and an object in a generic class V. The implementation code of HashtableChain uses a hash table with chaining for this purpose, but two methods are missing.

You must complete the coding of this class.

Using the HashtableChain class and the StringAndNumbers class we build a class for storing collection of StringAndNumbers objects as follows. An interface StorageInt.java presents a template for such a class. You must write a class Storage.java that implements this interface. The interface has the following public methods:

To store StringAndNumbers objects, we for example can do the following:

---------------------------------------
Hint: The aforementioned architecture allows you to substitute each word in the input text with a unique ID, which may become useful for possible future extensions. Note that the methods required in the interface can be implemented in a different manner. For example:

The last two alternatives are fine but the list only implementation is not permissible since a focus of this lab is on hashing. ---------------------------------------

One can write a code for storing words and their locations appearing in a given file and then obtaining the line numbers in which all the words in a given set of words appear. The code is given in StorageTest.java. Two sample text files are provided:

Both files are obtained through The Project Gutenberg.