diff options
author | trevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-21 22:42:52 +0000 |
---|---|---|
committer | trevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-21 22:42:52 +0000 |
commit | 2a69c7255fef37e9b8c2e63ed775d1dd9aaa8686 (patch) | |
tree | a26629610b352775196c650cb43d9ac93c1912f9 /gi/posterior-regularisation | |
parent | 8700e2ee96a71ed267617ce1ebd4ef3a002a1f6c (diff) |
Fixes to PR command line.
Added bilingual agreement model processing to pipeline.
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@365 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'gi/posterior-regularisation')
-rw-r--r-- | gi/posterior-regularisation/prjava/src/phrase/Agree2Sides.java | 17 | ||||
-rw-r--r-- | gi/posterior-regularisation/prjava/src/phrase/Trainer.java | 24 |
2 files changed, 28 insertions, 13 deletions
diff --git a/gi/posterior-regularisation/prjava/src/phrase/Agree2Sides.java b/gi/posterior-regularisation/prjava/src/phrase/Agree2Sides.java index 8bf0b93e..031f887f 100644 --- a/gi/posterior-regularisation/prjava/src/phrase/Agree2Sides.java +++ b/gi/posterior-regularisation/prjava/src/phrase/Agree2Sides.java @@ -157,13 +157,16 @@ public class Agree2Sides { public double[] posterior(int edgeIdx)
{
- Edge edge1=c1.getEdges().get(edgeIdx);
- Edge edge2=c2.getEdges().get(edgeIdx);
- double[] prob1=model1.posterior(edge1);
- double[] prob2=model2.posterior(edge2);
+ return posterior(c1.getEdges().get(edgeIdx), c2.getEdges().get(edgeIdx));
+ }
+
+ public double[] posterior(Edge e1, Edge e2)
+ {
+ double[] prob1=model1.posterior(e1);
+ double[] prob2=model2.posterior(e2);
- llh+=edge1.getCount()*Math.log(arr.F.l1norm(prob1));
- llh+=edge2.getCount()*Math.log(arr.F.l1norm(prob2));
+ llh+=e1.getCount()*Math.log(arr.F.l1norm(prob1));
+ llh+=e2.getCount()*Math.log(arr.F.l1norm(prob2));
arr.F.l1normalize(prob1);
arr.F.l1normalize(prob2);
@@ -177,7 +180,6 @@ public class Agree2Sides { public void displayPosterior(PrintStream ps)
{
-
for (int i=0;i<c1.getEdges().size();i++)
{
Edge edge=c1.getEdges().get(i);
@@ -192,5 +194,4 @@ public class Agree2Sides { ps.println(" ||| C=" + t);
}
}
-
}
diff --git a/gi/posterior-regularisation/prjava/src/phrase/Trainer.java b/gi/posterior-regularisation/prjava/src/phrase/Trainer.java index 202930f5..c1d4775e 100644 --- a/gi/posterior-regularisation/prjava/src/phrase/Trainer.java +++ b/gi/posterior-regularisation/prjava/src/phrase/Trainer.java @@ -166,8 +166,10 @@ public class Trainer last = o; } - if (cluster == null) + if (cluster == null && agree != null) cluster = agree.model1; + else if (cluster == null && agree2sides != null) + cluster = agree2sides.model1; double pl1lmax = cluster.phrase_l1lmax(); double cl1lmax = cluster.context_l1lmax(); @@ -183,11 +185,23 @@ public class Trainer test = corpus.getEdges(); else { // if --test supplied, load up the file - infile = (File) options.valueOf("test"); - System.out.println("Reading testing concordance from " + infile); - test = corpus.readEdges(FileUtil.reader(infile)); + if (agree == null && agree2sides == null) + { + infile = (File) options.valueOf("test"); + System.out.println("Reading testing concordance from " + infile); + test = corpus.readEdges(FileUtil.reader(infile)); + } + else + System.err.println("Can't run agreement models on different test data cf training (yet); --test ignored."); } - cluster.displayPosterior(ps, test); + + if (agree != null) + agree.displayPosterior(ps); + else if (agree2sides != null) + agree2sides.displayPosterior(ps); + else + cluster.displayPosterior(ps, test); + ps.close(); } catch (IOException e) { System.err.println("Failed to open either testing file or output file"); |