Buggy code:
public class HierarchicalLDA { InstanceList instances ; InstanceList testing ; HierarchicalLDA . NCRPNode rootNode ; HierarchicalLDA . NCRPNode node ; int numLevels ; int numDocuments ; int numTypes ; double alpha ; double gamma ; double eta ; double etaSum ; int [ ] [ ] levels ; HierarchicalLDA . NCRPNode [ ] documentLeaves ; int totalNodes = 0 ; String stateFile = "hlda.state" ; Randoms random ; boolean showProgress = true ; int displayTopicsInterval = 50 ; int numWordsToDisplay = 10 ; public HierarchicalLDA ( ) { } public void setAlpha ( double alpha ) { } public void setGamma ( double gamma ) { } public void setEta ( double eta ) { } public void setStateFile ( String stateFile ) { } public void setTopicDisplay ( int interval , int words ) { } public void setProgressDisplay ( boolean showProgress ) { } public void initialize ( InstanceList instances , InstanceList testing , int numLevels , Randoms random ) { } public void estimate ( int numIterations ) { } public void samplePath ( int doc , int iteration ) { } public void calculateNCRP ( TObjectDoubleHashMap < HierarchicalLDA . NCRPNode > nodeWeights , HierarchicalLDA . NCRPNode node , double weight ) { } public void calculateWordLikelihood ( TObjectDoubleHashMap < HierarchicalLDA . NCRPNode > nodeWeights , HierarchicalLDA . NCRPNode node , double weight , TIntIntHashMap [ ] typeCounts , double [ ] newTopicWeights , int level , int iteration ) { } public void propagateTopicWeight ( TObjectDoubleHashMap < HierarchicalLDA . NCRPNode > nodeWeights , HierarchicalLDA . NCRPNode node , double weight ) { } public void sampleTopics ( int doc ) { } public void printState ( ) throws FileNotFoundException , IOException { } public void printState ( PrintWriter out ) throws IOException { } public void printNodes ( ) { } public void printNode ( HierarchicalLDA . NCRPNode node , int indent ) { } public double empiricalLikelihood ( int numSamples , InstanceList testing ) { } public static void main ( String [ ] args ) { } class NCRPNode { int customers ; ArrayList < HierarchicalLDA . NCRPNode > children ; HierarchicalLDA . NCRPNode parent ; int level ; int totalTokens ; int [ ] typeCounts ; public int nodeID ; public NCRPNode ( HierarchicalLDA . NCRPNode parent , int dimensions , int level ) { } public NCRPNode ( int dimensions ) { } public HierarchicalLDA . NCRPNode addChild ( ) { } public boolean isLeaf ( ) { } public HierarchicalLDA . NCRPNode getNewLeaf ( ) { } public void dropPath ( ) { } public void remove ( HierarchicalLDA . NCRPNode node ) { } public void addPath ( ) { } public HierarchicalLDA . NCRPNode selectExisting ( ) { } public HierarchicalLDA . NCRPNode select ( ) { } public String getTopWords ( int numWords ) { IDSorter [ ] sortedTypes = new IDSorter [ numTypes ] ; for ( int type = 0 ; type < ( numTypes ) ; type ++ ) { sortedTypes [ type ] = new IDSorter ( type , typeCounts [ type ] ) ; } Arrays . sort ( sortedTypes ) ; Alphabet alphabet = instances . getDataAlphabet ( ) ; StringBuffer out = new StringBuffer ( ) ; <START_BUG> for ( int i = 0 ; i < 10 ; i ++ ) { <END_BUG> out . append ( ( ( alphabet . lookupObject ( sortedTypes [ i ] . getID ( ) ) ) + "<seq2seq4repair_space>" ) ) ; } return out . toString ( ) ; } } }

Fix:
for ( int i = 0 ; i < numWords ; i ++ ) {