private ViterbiNode findGlueNodeCandidate ( int index , ViterbiNode [ ] latticeNodes , int startIndex ) { List < ViterbiNode > candidates = new ArrayList <> ( ) ; for ( ViterbiNode viterbiNode : latticeNodes ) { if ( viterbiNode != null ) { candidates . add ( viterbiNode ) ; } } if ( ! candidates . isEmpty ( ) ) { ViterbiNode glueBase = null ; int length = index + 1 - startIndex ; for ( ViterbiNode candidate : candidates ) { if ( isAcceptableCandidate ( length , glueBase , candidate ) ) { glueBase = candidate ; } } if ( glueBase != null ) { return glueBase ; } } return null ; }
Tries to locate a candidate for a glue node that repairs the broken lattice by looking at all nodes at the current index .