double threshold, FlexibleMap canonical, boolean deriveOtherModelCounts) { if (useSmoothingParams || dontAddNewParams) readSmoothingParams(); setCanonicalEvents(canonical);   Time time = null; if (verbose) time = new Time();  Transition trans = new Transition(null, null);  Iterator entries = trainerCounts.entrySet().iterator(); while (entries.hasNext()) { MapToPrimitive.Entry entry = (MapToPrimitive.Entry)entries.next(); TrainerEvent event = (TrainerEvent)entry.getKey(); double count = entry.getDoubleValue(); if (!filter.pass(event)) continue;   for (int level = 0; level < numLevels; level++) { Event history = structure.getHistory(event, level); if (useSmoothingParams || dontAddNewParams) if (smoothingParams[level].containsKey(history) == false) continue; history = canonicalizeEvent(history, canonical); counts[level].history().add(history, CountsTrio.hist, count);  Event future = structure.getFuture(event, level); trans.setFuture(canonicalizeEvent(future, canonical)); trans.setHistory(history);  if (verboseDebug) System.err.println(shortStructureClassName + "(" + level + "): " + trans + "; count=" + (float)count);  if (counts[level].transition().count(trans) == 0) counts[level].history().add(trans.history(), CountsTrio.diversity); counts[level].transition().add(getCanonical(trans, canonical), count); } }  if (verbose) System.err.println("Derived transitions for " + structureClassName + " in " + time + ".");       if (precomputeProbs) savePrecomputeData(trainerCounts, filter);
double threshold, FlexibleMap canonical) { deriveCounts(trainerCounts, filter, threshold, canonical, false);
  public void deriveCounts(CountsTable trainerCounts, Filter filter,			   double threshold, FlexibleMap canonical,			   boolean deriveOtherModelCounts) {    if (useSmoothingParams || dontAddNewParams)      readSmoothingParams();    setCanonicalEvents(canonical);    //deriveHistories(trainerCounts, filter, canonical);    Time time = null;    if (verbose)      time = new Time();    Transition trans = new Transition(null, null);    Iterator entries = trainerCounts.entrySet().iterator();    while (entries.hasNext()) {      MapToPrimitive.Entry entry = (MapToPrimitive.Entry)entries.next();      TrainerEvent event = (TrainerEvent)entry.getKey();      double count = entry.getDoubleValue();      if (!filter.pass(event))	continue;      // store all transitions for all levels      for (int level = 0; level < numLevels; level++) {        Event history = structure.getHistory(event, level);        if (useSmoothingParams || dontAddNewParams)          if (smoothingParams[level].containsKey(history) == false)            continue;        history = canonicalizeEvent(history, canonical);        counts[level].history().add(history, CountsTrio.hist, count);        Event future = structure.getFuture(event, level);        trans.setFuture(canonicalizeEvent(future, canonical));        trans.setHistory(history);        if (verboseDebug)          System.err.println(shortStructureClassName +                             "(" + level + "): " + trans +                             "; count=" + (float)count);        if (counts[level].transition().count(trans) == 0)          counts[level].history().add(trans.history(), CountsTrio.diversity);        counts[level].transition().add(getCanonical(trans, canonical), count);      }    }    if (verbose)      System.err.println("Derived transitions for " + structureClassName +			 " in " + time + ".");    /*    if (threshold > 1) {      pruneHistoriesAndTransitions(threshold);    }    */    //deriveDiversityCounts();    /*    if (precomputeProbs)      precomputeProbs(trainerCounts, filter);    */   if (precomputeProbs)     savePrecomputeData(trainerCounts, filter);   /*   if (structure.doCleanup())     cleanup();   */  }