Return-Path: X-Original-To: apmail-incubator-opennlp-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-opennlp-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 30FCE2F91 for ; Tue, 3 May 2011 09:50:16 +0000 (UTC) Received: (qmail 72255 invoked by uid 500); 3 May 2011 09:50:16 -0000 Delivered-To: apmail-incubator-opennlp-commits-archive@incubator.apache.org Received: (qmail 72234 invoked by uid 500); 3 May 2011 09:50:16 -0000 Mailing-List: contact opennlp-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: opennlp-dev@incubator.apache.org Delivered-To: mailing list opennlp-commits@incubator.apache.org Received: (qmail 72221 invoked by uid 99); 3 May 2011 09:50:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 May 2011 09:50:15 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 May 2011 09:50:13 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6756723889BB; Tue, 3 May 2011 09:49:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1098989 - /incubator/opennlp/trunk/opennlp-maxent/src/main/java/opennlp/maxent/GISTrainer.java Date: Tue, 03 May 2011 09:49:52 -0000 To: opennlp-commits@incubator.apache.org From: joern@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110503094952.6756723889BB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: joern Date: Tue May 3 09:49:52 2011 New Revision: 1098989 URL: http://svn.apache.org/viewvc?rev=1098989&view=rev Log: OPENNLP-29 Inlined CFMOD variable and did minor refactoring Modified: incubator/opennlp/trunk/opennlp-maxent/src/main/java/opennlp/maxent/GISTrainer.java Modified: incubator/opennlp/trunk/opennlp-maxent/src/main/java/opennlp/maxent/GISTrainer.java URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-maxent/src/main/java/opennlp/maxent/GISTrainer.java?rev=1098989&r1=1098988&r2=1098989&view=diff ============================================================================== --- incubator/opennlp/trunk/opennlp-maxent/src/main/java/opennlp/maxent/GISTrainer.java (original) +++ incubator/opennlp/trunk/opennlp-maxent/src/main/java/opennlp/maxent/GISTrainer.java Tue May 3 09:49:52 2011 @@ -57,7 +57,7 @@ class GISTrainer { /** * Specifies whether a slack parameter should be used in the model. */ - private boolean useSlackParameter = false; + private final boolean useSlackParameter = false; /** * Specified whether parameter updates should prefer a distribution of parameters which @@ -72,7 +72,7 @@ class GISTrainer { // actually didn't see. Defaulted to 0.1. private double _smoothingObservation = 0.1; - private boolean printMessages = false; + private final boolean printMessages; /** * Number of unique events which occured in the event set. @@ -155,23 +155,13 @@ class GISTrainer { */ private double cfObservedExpect; - /** - * A global variable for the models expected value of the correction feature. - */ - private double CFMOD; + private static final double NEAR_ZERO = 0.01; + private static final double LLThreshold = 0.0001; - private final double NEAR_ZERO = 0.01; - private final double LLThreshold = 0.0001; - - /** - * Stores the number of features that get fired per event. - */ - int[] numfeats; - /** * Initial probability for all outcomes. */ - EvalParameters evalParams; + private EvalParameters evalParams; /** * Creates a new GISTrainer instance which does not print @@ -179,7 +169,7 @@ class GISTrainer { * */ GISTrainer() { - super(); + printMessages = false; } /** @@ -189,7 +179,6 @@ class GISTrainer { * STDOUT when true; trains silently otherwise. */ GISTrainer(boolean printMessages) { - this(); this.printMessages = printMessages; } @@ -410,8 +399,6 @@ class GISTrainer { display("...done.\n"); - numfeats = new int[numOutcomes]; - /***************** Find the parameters ************************/ display("Computing model parameters...\n"); findParameters(iterations, correctionConstant); @@ -487,7 +474,7 @@ class GISTrainer { // correction parameter double[] modelDistribution = new double[numOutcomes]; double loglikelihood = 0.0; - CFMOD = 0.0; + double CFMOD = 0.0; int numEvents = 0; int numCorrect = 0; for (int ei = 0; ei < numUniqueEvents; ei++) { @@ -565,7 +552,8 @@ class GISTrainer { evalParams.setCorrectionParam(evalParams.getCorrectionParam() + (cfObservedExpect - Math.log(CFMOD))); display(". loglikelihood=" + loglikelihood + "\t" + ((double) numCorrect / numEvents) + "\n"); - return (loglikelihood); + + return loglikelihood; } private void display(String s) {