public String [ ] sequencesToTexts ( Integer [ ] [ ] sequences ) { Integer oovTokenIndex = wordIndex . get ( outOfVocabularyToken ) ; ArrayList < String > texts = new ArrayList <> ( ) ; for ( Integer [ ] sequence : sequences ) { ArrayList < String > wordVector = new ArrayList <> ( ) ; for ( Integer index : sequence ) { if ( indexWord . containsKey ( index ) ) { String word = indexWord . get ( index ) ; if ( numWords != null && index >= numWords ) { if ( oovTokenIndex != null ) { wordVector . add ( indexWord . get ( oovTokenIndex ) ) ; } else { wordVector . add ( word ) ; } } } else if ( oovTokenIndex != null ) { wordVector . add ( indexWord . get ( oovTokenIndex ) ) ; } } StringBuilder builder = new StringBuilder ( ) ; for ( String word : wordVector ) { builder . append ( word + split ) ; } String text = builder . toString ( ) ; texts . add ( text ) ; } return texts . toArray ( new String [ texts . size ( ) ] ) ; }
Turns index sequences back into texts