private void repairBrokenLatticeAfter ( ViterbiLattice lattice , int nodeEndIndex ) { ViterbiNode [ ] [ ] nodeEndIndices = lattice . getEndIndexArr ( ) ; for ( int endIndex = nodeEndIndex + 1 ; endIndex < nodeEndIndices . length ; endIndex ++ ) { if ( nodeEndIndices [ endIndex ] != null ) { ViterbiNode glueBase = findGlueNodeCandidate ( nodeEndIndex , nodeEndIndices [ endIndex ] , endIndex ) ; if ( glueBase != null ) { int delta = endIndex - nodeEndIndex ; String glueBaseSurface = glueBase . getSurface ( ) ; String surface = glueBaseSurface . substring ( glueBaseSurface . length ( ) - delta ) ; ViterbiNode glueNode = createGlueNode ( nodeEndIndex , glueBase , surface ) ; lattice . addNode ( glueNode , nodeEndIndex , nodeEndIndex + glueNode . getSurface ( ) . length ( ) ) ; return ; } } } }
Tries to repair the lattice by creating and adding an additional Viterbi node to the RIGHT of the newly inserted user dictionary entry by using the substring of the node in the lattice that overlaps the least