For this homework, you will create a FileIndex
class that implements the ForwardIndex
interface and provide missing default
implementations in the ForwardIndex
interface itself.
The ForwardIndex
interface provides methods useful for any forward index that maps a generic location (like a file Path
or webpage URL
) to the words found at those locations.
The FileIndex
class implements the interface to work specifically for text file Path
locations and the unique words found at that location.
Your search engine project will rely heavily on the underlying inverted index data structure used to store word stems, locations, and positions. Understanding how to utilize concepts like the use of generic types, interfaces, default implementations, and mutability in the design of a custom data structure is useful for refactoring your inverted index data structure (after you have a functional approach).
<aside> <img src="/icons/git_gray.svg" alt="/icons/git_gray.svg" width="40px" /> This homework assignment provides an example of the types of methods to include in a data structure class, which might be useful for your project. It is not necessary, however, to use interfaces or generic types in the project.
</aside>
Below are some hints that may help with this homework assignment:
The code will not compile until you implement the ForwardIndex
interface in the FileIndex
class for Path
objects properly.
Focus on the the FileIndex
methods and tests first. Work on the two TODO
comments in ForwardIndex
last.
When creating a default
implementation, you can call other methods in the interface even if they are not implemented!
Remember, the default
methods will be inherited into the classes implements it. If it helps, imagine what the implementation should be when it gets inherited into the FileIndex
class.
Most of the implementations require 1 to 3 lines of code.
These hints are optional. There may be multiple approaches to solving this homework.