rightSubcatModel.deriveCounts(headEvents, allPass);
rightSubcatModel.deriveCounts(headEvents, nonTop);
  public void deriveCounts() {    try {      String globalModelStructureNumber =	Settings.get(Settings.globalModelStructureNumber);      if (globalModelStructureNumber == null) {	globalModelStructureNumber = "1";      }      System.err.println(className + ": using global model structure number " +			 globalModelStructureNumber);      Model lexPriorModel =	new Model(getProbStructure(lexPriorModelStructureClassnamePrefix,				   globalModelStructureNumber,				   Settings.lexPriorModelStructureNumber,				   Settings.lexPriorModelStructureClass));      Model nonterminalPriorModel =	new Model(getProbStructure(nonterminalPriorModelStructureClassnamePrefix,				   globalModelStructureNumber,				   Settings.nonterminalPriorModelStructureNumber,				   Settings.nonterminalPriorModelStructureClass));      Model topNonterminalModel =	new Model(getProbStructure(topNonterminalModelStructureClassnamePrefix,				   globalModelStructureNumber,				   Settings.topNonterminalModelStructureNumber,				   Settings.topNonterminalModelStructureClass));      Model topLexModel =	new Model(getProbStructure(topLexModelStructureClassnamePrefix,				   globalModelStructureNumber,				   Settings.topLexModelStructureNumber,				   Settings.topLexModelStructureClass));      Model headModel =	new Model(getProbStructure(headModelStructureClassnamePrefix,				   globalModelStructureNumber,				   Settings.headModelStructureNumber,				   Settings.headModelStructureClass));      Model gapModel =	new Model(getProbStructure(gapModelStructureClassnamePrefix,				   globalModelStructureNumber,				   Settings.gapModelStructureNumber,				   Settings.gapModelStructureClass));      Model leftSubcatModel =	new Model(getProbStructure(leftSubcatModelStructureClassnamePrefix,				   globalModelStructureNumber,				   Settings.leftSubcatModelStructureNumber,				   Settings.leftSubcatModelStructureClass));      Model rightSubcatModel =	new Model(getProbStructure(rightSubcatModelStructureClassnamePrefix,				   globalModelStructureNumber,				   Settings.rightSubcatModelStructureNumber,				   Settings.rightSubcatModelStructureClass));      Model leftModNonterminalModel =	new Model(getProbStructure(modNonterminalModelStructureClassnamePrefix,				   globalModelStructureNumber,				   Settings.modNonterminalModelStructureNumber,				   Settings.modNonterminalModelStructureClass));      Model rightModNonterminalModel =	new Model(getProbStructure(modNonterminalModelStructureClassnamePrefix,				   globalModelStructureNumber,				   Settings.modNonterminalModelStructureNumber,				   Settings.modNonterminalModelStructureClass));      Model leftModWordModel =	new Model(getProbStructure(modWordModelStructureClassnamePrefix,				   globalModelStructureNumber,				   Settings.modWordModelStructureNumber,				   Settings.modWordModelStructureClass));      Model rightModWordModel =	new Model(getProbStructure(modWordModelStructureClassnamePrefix,				   globalModelStructureNumber,				   Settings.modWordModelStructureNumber,				   Settings.modWordModelStructureClass));      HashMap canonicalEventLists = new HashMap();      Filter allPass = new AllPass();      Filter nonTop = new Filter() {	  public boolean pass(Object obj) {	    return ((TrainerEvent)obj).parent() != topSym;	  }	};      Filter topOnly = new Filter() {	  public boolean pass(Object obj) {	    return ((TrainerEvent)obj).parent() == topSym;	  }	};      Filter leftOnly = new Filter() {	  public boolean pass(Object obj) {	    return ((TrainerEvent)obj).side() == Constants.LEFT;	  }	};      Filter rightOnly = new Filter() {	  public boolean pass(Object obj) {	    return ((TrainerEvent)obj).side() == Constants.RIGHT;	  }	};      System.err.print("Deriving events for prior probability computations...");      derivePriors();      System.err.println("done.");      lexPriorModel.deriveCounts(priorEvents, allPass);      lexPriorModel.canonicalize(canonicalEventLists);      nonterminalPriorModel.deriveCounts(priorEvents, allPass);      nonterminalPriorModel.canonicalize(canonicalEventLists);      topNonterminalModel.deriveCounts(headEvents, topOnly);      topNonterminalModel.canonicalize(canonicalEventLists);      topLexModel.deriveCounts(headEvents, topOnly);      topLexModel.canonicalize(canonicalEventLists);      headModel.deriveCounts(headEvents, nonTop);      headModel.canonicalize(canonicalEventLists);      gapModel.deriveCounts(gapEvents, allPass);      gapModel.canonicalize(canonicalEventLists);      leftSubcatModel.deriveCounts(headEvents, allPass);      leftSubcatModel.canonicalize(canonicalEventLists);      rightSubcatModel.deriveCounts(headEvents, allPass);      rightSubcatModel.canonicalize(canonicalEventLists);      leftModNonterminalModel.deriveCounts(modifierEvents, leftOnly);      leftModNonterminalModel.canonicalize(canonicalEventLists);      rightModNonterminalModel.deriveCounts(modifierEvents, rightOnly);      rightModNonterminalModel.canonicalize(canonicalEventLists);      leftModWordModel.deriveCounts(modifierEvents, leftOnly);      leftModWordModel.canonicalize(canonicalEventLists);      rightModWordModel.deriveCounts(modifierEvents, rightOnly);      rightModWordModel.canonicalize(canonicalEventLists);      deriveSubcatMaps(leftSubcatModel.getProbStructure(),		       rightSubcatModel.getProbStructure());      canonicalEventLists = null;      System.err.print("gc ... ");      System.err.flush();      System.gc();      System.err.println("done");      modelCollection.set(lexPriorModel,			  nonterminalPriorModel,			  topNonterminalModel,			  topLexModel,			  headModel,			  gapModel,			  leftSubcatModel,			  rightSubcatModel,			  leftModNonterminalModel,			  rightModNonterminalModel,			  leftModWordModel,			  rightModWordModel,			  vocabCounter,			  wordFeatureCounter,			  nonterminals,			  posMap,			  leftSubcatMap,			  rightSubcatMap);    }    catch (ExceptionInInitializerError e) {      System.err.println(className + ": problem initializing an instance of " +			 "a model class: " + e);    }    catch (LinkageError e) {      System.err.println(className + ": problem linking a model class: " + e);    }    catch (ClassNotFoundException e) {      System.err.println(className + ": couldn't find a model class: " + e);    }    catch (InstantiationException e) {      System.err.println(className + ": couldn't instantiate a model class: " +			 e);    }    catch (IllegalAccessException e) {      System.err.println(className + ": not allowed to instantiate a model " +			 "class: " + e);    }  }