if (trainingFilename != null && objectOutputFilename == null) {
if (trainerEventInputFilename != null && objectOutputFilename == null) {
  public static void main(String[] args) {    boolean stripOuterParens = false, auto = true;    boolean incrementalTraining = false;    String trainingFilename = null, outputFilename = null, inputFilename = null;    String trainerEventInputFilename = null;    String settingsFilename = null, objectOutputFilename = null;    String objectInputFilename = null, scanObjectFilename = null;    // process arguments    for (int i = 0; i < args.length; i++) {      if (args[i].charAt(0) == '-') {	if (args[i].equals("-i")) {	  if (i + 1 == args.length)	    usage();	  trainingFilename = args[++i];	}	else if (args[i].equals("-o")) {	  if (i + 1 == args.length)	    usage();	  outputFilename = args[++i];	}	else if (args[i].equals("-od")) {	  if (i + 1 == args.length)	    usage();	  objectOutputFilename = args[++i];	}	else if (args[i].equals("-ld")) {	  if (i + 1 == args.length)	    usage();	  objectInputFilename = args[++i];	}	else if (args[i].equals("-scan")) {	  if (i + 1 == args.length)	    usage();	  scanObjectFilename = args[++i];	}	else if (args[i].equals("-sf") || args[i].equals("--settings")) {	  if (i + 1 == args.length)	    usage();	  settingsFilename = args[++i];	}	else if (args[i].equals("-l")) {	  if (i + 1 == args.length)	    usage();          if (inputFilename == null)            inputFilename = args[++i];          else            trainerEventInputFilename = args[++i];	}	else if (args[i].equals("--strip-outer-parens")) {	  stripOuterParens = true;	  auto = false;	}	else if (args[i].equals("--dont-strip-outer-parens")) {	  stripOuterParens = false;	  auto = false;	}	else if (args[i].equals("-auto"))	  auto = true;        else if (args[i].equals("-it") ||                 args[i].equals("--incremental-training"))          incrementalTraining = true;	else if (args[i].equals("-help"))	  usage();	else {	  System.err.println("\nunrecognized flag: " + args[i]);	  usage();	}      }    }    if (scanObjectFilename == null && objectInputFilename == null &&	trainingFilename == null && outputFilename == null &&	inputFilename == null)      usage();    if (trainingFilename != null && trainerEventInputFilename != null) {      System.err.println("\nerror: cannot specify both a trainer event input " +                         "file and an\n\tobservation input file\n");      usage();    }    if (incrementalTraining &&        !(inputFilename != null && objectOutputFilename != null)) {      System.err.println("\nerror: must specify both <input file> and " +                         "<derived data output file>\n\twith -it option\n");      usage();    }    if (trainingFilename != null && objectOutputFilename == null) {      System.err.println("\nerror: must specify a <derived data output " +                         "file> when specifying <trainer event input file> " +                         "with second \"-l\"\n");      usage();    }    try {      if (settingsFilename != null)	Settings.load(settingsFilename);    }    catch (IOException ioe) {      System.err.println("\nwarning: problem loading settings file \"" +			 settingsFilename + "\"\n");    }    String encoding = Language.encoding();    Trainer trainer = null;    try {      trainer = (Trainer)trainerClass.newInstance();    }    catch (Exception e) {      System.err.println(e);      System.exit(1);    }    try {      if (scanObjectFilename != null) {	try {	  trainer.scanModelCollectionObjectFile(scanObjectFilename,						System.err);	}	catch (ClassNotFoundException cnfe) {	  System.err.println(cnfe);	}	catch (OptionalDataException ode) {	  System.err.println(ode);	}      }      Time overallTime = new Time();      Time trainingTime = new Time();      if (objectOutputFilename != null)        trainer.createModelObjects();      if (inputFilename != null) {        Time time = new Time();        System.err.println("Loading observations from \"" + inputFilename +                           "\".");        if (incrementalTraining) {          // user can only specify to do incremental training when user          // wants to derive counts          incrementallyTrain(trainer, inputFilename);        }        else {          trainer.readStats(new File(inputFilename));        }        if (trainerEventInputFilename != null) {          // user may only specify a trainer event input filename along with          // an object output file, so we know that user must want to derive          // counts from this trainer event input file          incrementallyTrain(trainer, trainerEventInputFilename);        }        System.err.println("Finished reading observations in " + time + ".");      }      if (trainingFilename != null) {	System.err.println("Training from trees in \"" +			   trainingFilename + "\".");	Time time = new Time();	trainer.train(new SexpTokenizer(trainingFilename, encoding,					Constants.defaultFileBufsize),		      auto, stripOuterParens);	System.err.println("Observation collection completed in " + time + ".");      }      if (inputFilename != null || trainingFilename != null) {	trainer.doneCollectingObservations();      }      if (outputFilename != null) {	OutputStream os =	  (outputFilename.equals("-") ?	   (OutputStream)System.out : new FileOutputStream(outputFilename));	Writer writer = new BufferedWriter(new OutputStreamWriter(os, encoding),					   Constants.defaultFileBufsize);	System.err.println("Writing observations to output file \"" +			   outputFilename + "\".");	Time time = new Time();	trainer.writeStats(writer);	writer.close();	System.err.println("Finished writing observations in " + time + ".");      }      if (trainingFilename != null && outputFilename != null &&	  inputFilename != null) {	System.err.println("Training completed in " + trainingTime + ".");	System.err.print("Cleaning symbol table...");	System.err.flush();	Symbol.clean();	System.err.println("done.");      }      if (objectOutputFilename != null) {	System.err.println("Deriving counts.");	Time time1 = new Time();	trainer.deriveCounts();	System.err.println("Finished deriving counts in " + time1 + ".\n" +			   "Writing out all derived counts to object file \"" +			   objectOutputFilename + "\".");	Time time2 = new Time();	trainer.writeModelCollection(objectOutputFilename,				     trainingFilename, outputFilename);	System.err.println("Finished outputting derived counts in " +			   time2 + ".");      }      if (objectInputFilename != null) {	try {	  System.err.println("Loading derived counts from \"" +			     objectInputFilename + "\".");	  Time time = new Time();	  trainer.setModelCollection(objectInputFilename);	  System.err.println("Finished loading derived counts in "+ time +".");	  System.err.print("gc ... ");	  System.err.flush();	  System.gc();	  System.err.println("done");	  Runtime runtime = Runtime.getRuntime();	  System.err.println("Memory usage: " +			     (runtime.totalMemory() - runtime.freeMemory())+			     " bytes.");	}	catch (ClassNotFoundException cnfe) {	  System.err.println(cnfe);	}	catch (OptionalDataException ode) {	  System.err.println(ode);	}      }      System.err.println("\nTotal elapsed time: " + overallTime + ".");      System.err.println("\nHave a nice day!");    }    catch (UnsupportedEncodingException uee) {      System.err.println(uee);    }    catch (FileNotFoundException fnfe) {      System.err.println(fnfe);    }    catch (IOException ioe) {      System.err.println(ioe);    }  }