java.lang.Object
test.Dictionary
-
Constructor Summary
ConstructorsConstructorDescriptionDictionary(String... fileNames) The Dictionary function is the constructor of the class, takes in a list of file names and creates a dictionary that contains all the words from those files. -
Method Summary
-
Constructor Details
-
Dictionary
The Dictionary function is the constructor of the class, takes in a list of file names and creates a dictionary that contains all the words from those files. It also creates two caches, one using LFU and another using LRU. The cache size for LFU is 100 while the cache size for LRU is 400.- Parameters:
fileNames- An array of String
-
-
Method Details
-
query
The query function takes in a word and returns whether the word is contained within the Bloom Filter. If it is, then we add it to our cache of recently used words (cLRU). If it isn't, then we add it to our cache of frequently used words (cLFU). This way, if a user searches for a word that isn't in the Bloom Filter but has been searched for before by other users, they will be notified that this particular word was not found. However, if they search for something that's never been searched before, it adds to the necessary CacheManager.- Parameters:
word- String Check if the word is in the cache- Returns:
- True if the word is in the LRU or in the BloomFilter and false otherwise.
-
challenge
The challenge function takes in a string and checks if it is valid. The function search through all of our files using IOSearcher to find out if that word exists in any of them.- Parameters:
word- String -Search the word in the file- Returns:
- A boolean
-