package hw.bst;

import java.io.FileNotFoundException;
import java.util.ArrayList;

public class TreeAnalysis {

  //-----------------------------------------------------
  // Add helper methods to answer the individual questions.
  //-----------------------------------------------------


  /**
   * Main method to analyze a text file and answer all assignment questions.
   *
   * @param args Command line arguments (filename)
   */
  public static void main(String[] args) {
    if (args.length < 1) {
      System.out.println("Usage: TreeAnalysis <filename>");
      return;
    }

    try {
      String filename = args[0];

      // Build the index
      BSTDictionary<String, ArrayList<Integer>> index = TextIndexer.indexFile(filename);

      //-----------------------------------------------------
      // Call your methods here and print relevant results.
      //-----------------------------------------------------

    } catch (FileNotFoundException e) {
      System.err.println("Error: File not found - " + args[0]);
    } catch (Exception e) {
      System.err.println("Error: " + e.getMessage());
      e.printStackTrace();
    }
  }
}
