public double scoreOf ( int [ ] sequence ) { int [ ] given = new int [ window ( ) - 1 ] ; Arrays . fill ( given , classIndex . indexOf ( backgroundSymbol ) ) ; double logProb = 0 ; for ( int i = 0 ; i < length ( ) ; i ++ ) { int label = sequence [ i ] ; logProb += condLogProbGivenPrevious ( i , label , given ) ; System . arraycopy ( given , 1 , given , 0 , given . length - 1 ) ; given [ given . length - 1 ] = label ; } return logProb ; }
Returns the log probability of this sequence given the CRF . Does so by computing the marginal of the first windowSize tags and then computing the conditional probability for the rest of them conditioned on the previous tags .