private void repairBrokenLatticeBefore ( ViterbiLattice lattice , int index ) { ViterbiNode [ ] [ ] nodeStartIndices = lattice . getStartIndexArr ( ) ; for ( int startIndex = index ; startIndex > 0 ; startIndex -- ) { if ( nodeStartIndices [ startIndex ] != null ) { ViterbiNode glueBase = findGlueNodeCandidate ( index , nodeStartIndices [ startIndex ] , startIndex ) ; if ( glueBase != null ) { int length = index + 1 - startIndex ; String surface = glueBase . getSurface ( ) . substring ( 0 , length ) ; ViterbiNode glueNode = createGlueNode ( startIndex , glueBase , surface ) ; lattice . addNode ( glueNode , startIndex , startIndex + glueNode . getSurface ( ) . length ( ) ) ; return ; } } } }
Tries to repair the lattice by creating and adding an additional Viterbi node to the LEFT of the newly inserted user dictionary entry by using the substring of the node in the lattice that overlaps the least