/** Constructor takes a CorpusArray and creates a sorted suffix array from it. */
  public SuffixArray(CorpusArray corpusArray) {
    this.corpus = corpusArray;
    suffixes = new int[corpusArray.size()];

    // Create an array of suffix IDs
    for (int i = 0; i < corpusArray.size(); i++) {
      suffixes[i] = i;
    }
    // Sort the array of suffixes
    sort(suffixes);

    this.hierarchicalPhraseCache = new Cache<Pattern, HierarchicalPhrases>(CACHE_CAPACITY);
  }
 /**
  * Creates a string of the semi-infinite strings in the corpus array. Only use this on small
  * suffixArrays!
  */
 public String toString() {
   String str = "";
   for (int i = 0; i < suffixes.length; i++) {
     Phrase phrase = corpus.getPhrase(getCorpusIndex(i), corpus.size());
     str += phrase.toString() + "\n";
   }
   return str;
 }
 /** Implemented for the Corpus interface. */
 public int getNumWords() {
   return corpus.size();
 }