@Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    InMemoryLookupCache that = (InMemoryLookupCache) o;

    if (numDocs != that.numDocs) return false;
    if (wordIndex != null ? !wordIndex.equals(that.wordIndex) : that.wordIndex != null)
      return false;
    if (wordFrequencies != null
        ? !wordFrequencies.equals(that.wordFrequencies)
        : that.wordFrequencies != null) return false;
    if (docFrequencies != null
        ? !docFrequencies.equals(that.docFrequencies)
        : that.docFrequencies != null) return false;
    if (vocabWords().equals(that.vocabWords())) return true;

    return true;
  }
  /**
   * Load a look up cache from an input stream delimited by \n
   *
   * @param from the input stream to read from
   * @return the in memory lookup cache
   */
  public static InMemoryLookupCache load(InputStream from) {
    Reader inputStream = new InputStreamReader(from);
    LineIterator iter = IOUtils.lineIterator(inputStream);
    String line;
    InMemoryLookupCache ret = new InMemoryLookupCache();
    int count = 0;
    while ((iter.hasNext())) {
      line = iter.nextLine();
      if (line.isEmpty()) continue;
      ret.incrementWordCount(line);
      VocabWord word = new VocabWord(1.0, line);
      word.setIndex(count);
      ret.addToken(word);
      ret.addWordToIndex(count, line);
      ret.putVocabWord(line);
      count++;
    }

    return ret;
  }