From: Thomas M. <tsm...@us...> - 2008-08-22 01:16:53
|
Update of /cvsroot/maxent/maxent/src/java/opennlp/maxent In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv8623/src/java/opennlp/maxent Modified Files: GISTrainer.java Log Message: fixed issue with real-valued features. Index: GISTrainer.java =================================================================== RCS file: /cvsroot/maxent/maxent/src/java/opennlp/maxent/GISTrainer.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** GISTrainer.java 12 Apr 2007 17:21:59 -0000 1.27 --- GISTrainer.java 22 Aug 2008 01:16:50 -0000 1.28 *************** *** 73,81 **** private int[][] contexts; ! /** The value associates with each context. If null then context values are assumes to be 1. */ private float[][] values; ! ! /** Records the array of outcomes seen in each event. */ ! private int[] outcomes; /** List of outcomes for each event i, in context[i]. */ private int[] outcomeList; --- 73,79 ---- private int[][] contexts; ! /** The value associated with each context. If null then context values are assumes to be 1. */ private float[][] values; ! /** List of outcomes for each event i, in context[i]. */ private int[] outcomeList; *************** *** 212,216 **** contexts = di.getContexts(); values = di.getValues(); - outcomes = di.getOutcomeList(); this.cutoff = cutoff; predicateCounts = di.getPredCounts(); --- 210,213 ---- *************** *** 242,249 **** // set up feature arrays ! int[][] predCount = new int[numPreds][numOutcomes]; for (int ti = 0; ti < numUniqueEvents; ti++) { for (int j = 0; j < contexts[ti].length; j++) { ! predCount[contexts[ti][j]][outcomeList[ti]] += numTimesEventsSeen[ti]; } } --- 239,251 ---- // set up feature arrays ! float[][] predCount = new float[numPreds][numOutcomes]; for (int ti = 0; ti < numUniqueEvents; ti++) { for (int j = 0; j < contexts[ti].length; j++) { ! if (values == null || values[ti] == null) { ! predCount[contexts[ti][j]][outcomeList[ti]] += numTimesEventsSeen[ti]; ! } ! else { ! predCount[contexts[ti][j]][outcomeList[ti]] += numTimesEventsSeen[ti]*values[ti][j]; ! } } } *************** *** 304,308 **** modelExpects[pi].setParameter(aoi, 0.0); if (predCount[pi][oi] > 0) { ! observedExpects[pi].setParameter(aoi, predCount[pi][oi]); } else if (useSimpleSmoothing) { --- 306,310 ---- modelExpects[pi].setParameter(aoi, 0.0); if (predCount[pi][oi] > 0) { ! observedExpects[pi].setParameter(aoi, predCount[pi][oi]); } else if (useSimpleSmoothing) { *************** *** 318,322 **** for (int j = 0; j < contexts[ti].length; j++) { int pi = contexts[ti][j]; ! if (!modelExpects[pi].contains(outcomes[ti])) { cfvalSum += numTimesEventsSeen[ti]; } --- 320,324 ---- for (int j = 0; j < contexts[ti].length; j++) { int pi = contexts[ti][j]; ! if (!modelExpects[pi].contains(outcomeList[ti])) { cfvalSum += numTimesEventsSeen[ti]; } *************** *** 443,447 **** CFMOD += (evalParams.correctionConstant - contexts[ei].length) * numTimesEventsSeen[ei]; ! loglikelihood += Math.log(modelDistribution[outcomes[ei]]) * numTimesEventsSeen[ei]; numEvents += numTimesEventsSeen[ei]; if (printMessages) { --- 445,449 ---- CFMOD += (evalParams.correctionConstant - contexts[ei].length) * numTimesEventsSeen[ei]; ! loglikelihood += Math.log(modelDistribution[outcomeList[ei]]) * numTimesEventsSeen[ei]; numEvents += numTimesEventsSeen[ei]; if (printMessages) { *************** *** 452,456 **** } } ! if (max == outcomes[ei]) { numCorrect += numTimesEventsSeen[ei]; } --- 454,458 ---- } } ! if (max == outcomeList[ei]) { numCorrect += numTimesEventsSeen[ei]; } |