private int MergeDuplicates() { int numMerged = 0; for (int i = 0; i < latticeWords.Count - 1; i++) { HTKLatticeReader.LatticeWord first = latticeWords[i]; for (int j = i + 1; j < latticeWords.Count; j++) { HTKLatticeReader.LatticeWord second = latticeWords[j]; if (first.Equals(second)) { if (Debug) { log.Info("removed duplicate"); } first.Merge(second); latticeWords.Remove(j); wordsStartAt[second.startNode].Remove(second); wordsEndAt[second.endNode].Remove(second); for (int k = second.startNode; k <= second.endNode; k++) { wordsAtTime[k].Remove(second); } numMerged++; j--; } } } return(numMerged); }