public double conditionalLogProbGivenPrevious ( int [ ] given , int of ) { if ( given . length != windowSize - 1 ) { throw new IllegalArgumentException ( "conditionalLogProbGivenPrevious requires given one less than clique size (" + windowSize + ") but was " + Arrays . toString ( given ) ) ; } // Note: other similar methods could be optimized like this one, but this is the one the CRF uses.... /* int startIndex = indicesFront(given); int numCellsToSum = SloppyMath.intPow(numClasses, windowSize - given.length); double z = ArrayMath.logSum(table, startIndex, startIndex + numCellsToSum); int i = indexOf(given, of); System.err.printf("startIndex is %d, numCellsToSum is %d, i is %d (of is %d)%n", startIndex, numCellsToSum, i, of); */ int startIndex = indicesFront ( given ) ; double z = ArrayMath . logSum ( table , startIndex , startIndex + numClasses ) ; int i = startIndex + of ; // System.err.printf("startIndex is %d, numCellsToSum is %d, i is %d (of is %d)%n", startIndex, numClasses, i, of); return table [ i ] - z ; }
Computes the probability of the tag OF being at the end of the table given that the previous tag sequence in table is GIVEN . given is at the beginning of is at the end .