From e0265b2c2be3173341bdc2ffacdb6847b30890f5 Mon Sep 17 00:00:00 2001 From: "trevor.cohn" Date: Tue, 13 Jul 2010 18:22:59 +0000 Subject: Cleaning up the PC model. git-svn-id: https://ws10smt.googlecode.com/svn/trunk@236 ec762483-ff6d-05da-a07a-a48fb63a330f --- gi/posterior-regularisation/prjava/Makefile | 2 +- gi/posterior-regularisation/prjava/src/arr/F.java | 9 ++ .../AbstractGradientBaseMethod.java | 9 +- .../projections/SimplexProjection.java | 2 +- .../prjava/src/phrase/PhraseCluster.java | 3 +- .../prjava/src/phrase/PhraseContextObjective.java | 155 ++++++++++----------- .../prjava/src/phrase/PhraseObjective.java | 3 +- 7 files changed, 94 insertions(+), 89 deletions(-) (limited to 'gi/posterior-regularisation/prjava') diff --git a/gi/posterior-regularisation/prjava/Makefile b/gi/posterior-regularisation/prjava/Makefile index abd9b964..a16adcde 100644 --- a/gi/posterior-regularisation/prjava/Makefile +++ b/gi/posterior-regularisation/prjava/Makefile @@ -1,5 +1,5 @@ all: - ant + ant dist clean: ant clean diff --git a/gi/posterior-regularisation/prjava/src/arr/F.java b/gi/posterior-regularisation/prjava/src/arr/F.java index 54dadeac..79de5d1a 100644 --- a/gi/posterior-regularisation/prjava/src/arr/F.java +++ b/gi/posterior-regularisation/prjava/src/arr/F.java @@ -56,6 +56,7 @@ public class F { } public static double l1norm(double a[]){ + // FIXME: this isn't the l1 norm for a < 0 double norm=0; for(int i=0;i> tasks = new ArrayList>(); - //System.out.println("projectPoint: " + Arrays.toString(point)); + //System.out.println("\t\tprojectPoint: " + Arrays.toString(point)); Arrays.fill(newPoint, 0, newPoint.length, 0); - if (scalePT > 0) + // first project using the phrase-tag constraints, + // for all p,t: sum_c lambda_ptc < scaleP + if (pool == null) { - // first project using the phrase-tag constraints, - // for all p,t: sum_c lambda_ptc < scaleP - if (pool == null) + for (int p = 0; p < c.c.getNumPhrases(); ++p) { - for (int p = 0; p < c.c.getNumPhrases(); ++p) + List edges = c.c.getEdgesForPhrase(p); + double[] toProject = new double[edges.size()]; + for(int tag=0;tag edges = c.c.getEdgesForPhrase(p); - double[] toProject = new double[edges.size()]; - for(int tag=0;tag edges = c.c.getEdgesForPhrase(phrase); + double toProject[] = new double[edges.size()]; + for(int tag=0;tag edges = c.c.getEdgesForPhrase(phrase); - double toProject[] = new double[edges.size()]; - for(int tag=0;tag 1e-6) + // now project using the context-tag constraints, + // for all c,t: sum_p omega_pct < scaleC + if (pool == null) { - // now project using the context-tag constraints, - // for all c,t: sum_p omega_pct < scaleC - if (pool == null) + for (int ctx = 0; ctx < c.c.getNumContexts(); ++ctx) { - for (int ctx = 0; ctx < c.c.getNumContexts(); ++ctx) + List edges = c.c.getEdgesForContext(ctx); + double toProject[] = new double[edges.size()]; + for(int tag=0;tag edges = c.c.getEdgesForContext(ctx); - double toProject[] = new double[edges.size()]; - for(int tag=0;tag edges = c.c.getEdgesForContext(context); + double toProject[] = new double[edges.size()]; + for(int tag=0;tag edges = c.c.getEdgesForContext(context); - double toProject[] = new double[edges.size()]; - for(int tag=0;tag