You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jo...@apache.org on 2011/05/23 16:01:07 UTC
svn commit: r1126494 -
/incubator/opennlp/trunk/opennlp-maxent/src/main/java/opennlp/maxent/GISTrainer.java
Author: joern
Date: Mon May 23 14:01:06 2011
New Revision: 1126494
URL: http://svn.apache.org/viewvc?rev=1126494&view=rev
Log:
OPENNLP-29 Refactoring, inlined variables in gaussianUpdate
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=1126494&r1=1126493&r2=1126494&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 Mon May 23 14:01:06 2011
@@ -430,20 +430,17 @@ class GISTrainer {
//modeled on implementation in Zhang Le's maxent kit
private double gaussianUpdate(int predicate, int oid, int n, double correctionConstant) {
double param = params[predicate].getParameters()[oid];
- double x = 0.0;
double x0 = 0.0;
- double tmp;
- double fp;
double modelValue = modelExpects[0][predicate].getParameters()[oid];
double observedValue = observedExpects[predicate].getParameters()[oid];
for (int i = 0; i < 50; i++) {
- tmp = modelValue * Math.exp(correctionConstant * x0);
+ double tmp = modelValue * Math.exp(correctionConstant * x0);
double f = tmp + (param + x0) / sigma - observedValue;
- fp = tmp * correctionConstant + 1 / sigma;
+ double fp = tmp * correctionConstant + 1 / sigma;
if (fp == 0) {
break;
}
- x = x0 - f / fp;
+ double x = x0 - f / fp;
if (Math.abs(x - x0) < 0.000001) {
x0 = x;
break;