Package test

Class Dictionary

java.lang.Object
test.Dictionary

public class Dictionary extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    Dictionary(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

    Modifier and Type
    Method
    Description
    boolean
    The challenge function takes in a string and checks if it is valid.
    boolean
    query(String word)
    The query function takes in a word and returns whether the word is contained within the Bloom Filter.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Dictionary

      public Dictionary(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. 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

      public boolean query(String word)
      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

      public boolean challenge(String word)
      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