protected Parse [ ] advanceTags ( final Parse p ) { final Parse [ ] children = p . getChildren ( ) ; final String [ ] words = new String [ children . length ] ; final double [ ] probs = new double [ words . length ] ; for ( int i = 0 , il = children . length ; i < il ; i ++ ) { words [ i ] = children [ i ] . getCoveredText ( ) ; } final Sequence [ ] ts = this . tagger . topKSequences ( words ) ; if ( ts . length == 0 ) { System . err . println ( "no tag sequence" ) ; } final Parse [ ] newParses = new Parse [ ts . length ] ; for ( int i = 0 ; i < ts . length ; i ++ ) { final String [ ] tags = ts [ i ] . getOutcomes ( ) . toArray ( new String [ words . length ] ) ; ts [ i ] . getProbs ( probs ) ; newParses [ i ] = ( Parse ) p . clone ( ) ; // copies top level if ( this . createDerivationString ) { newParses [ i ] . getDerivation ( ) . append ( i ) . append ( "." ) ; } for ( int j = 0 ; j < words . length ; j ++ ) { final Parse word = children [ j ] ; // System.err.println("inserting tag "+tags[j]); final double prob = probs [ j ] ; newParses [ i ] . insert ( new Parse ( word . getText ( ) , word . getSpan ( ) , tags [ j ] . replaceAll ( "-" + BioCodec . START , "" ) , prob , j ) ) ; newParses [ i ] . addProb ( Math . log ( prob ) ) ; // newParses[i].show(); } } return newParses ; }
Advances the parse by assigning it POS tags and returns multiple tag sequences .