From b6687bbea08eaa807214e7abca3ae6ff5557f4e4 Mon Sep 17 00:00:00 2001 From: desaicwtf Date: Tue, 20 Jul 2010 15:17:00 +0000 Subject: modified trainer for agreement of languages git-svn-id: https://ws10smt.googlecode.com/svn/trunk@333 ec762483-ff6d-05da-a07a-a48fb63a330f --- .../prjava/src/phrase/Trainer.java | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'gi/posterior-regularisation/prjava/src/phrase') diff --git a/gi/posterior-regularisation/prjava/src/phrase/Trainer.java b/gi/posterior-regularisation/prjava/src/phrase/Trainer.java index afc80724..f9fd8485 100644 --- a/gi/posterior-regularisation/prjava/src/phrase/Trainer.java +++ b/gi/posterior-regularisation/prjava/src/phrase/Trainer.java @@ -18,9 +18,11 @@ public class Trainer { public static void main(String[] args) { + OptionParser parser = new OptionParser(); parser.accepts("help"); parser.accepts("in").withRequiredArg().ofType(File.class); + parser.accepts("in1").withRequiredArg().ofType(File.class); parser.accepts("test").withRequiredArg().ofType(File.class); parser.accepts("out").withRequiredArg().ofType(File.class); parser.accepts("start").withRequiredArg().ofType(File.class); @@ -35,7 +37,8 @@ public class Trainer parser.accepts("variational-bayes"); parser.accepts("alpha-emit").withRequiredArg().ofType(Double.class).defaultsTo(0.1); parser.accepts("alpha-pi").withRequiredArg().ofType(Double.class).defaultsTo(0.01); - parser.accepts("agree"); + parser.accepts("agree-direction"); + parser.accepts("agree-language"); parser.accepts("no-parameter-cache"); parser.accepts("skip-large-phrases").withRequiredArg().ofType(Integer.class).defaultsTo(5); OptionSet options = parser.parse(args); @@ -73,17 +76,21 @@ public class Trainer Corpus corpus = null; File infile = (File) options.valueOf("in"); + Corpus corpus1 = null; + File infile1 = (File) options.valueOf("in1"); try { System.out.println("Reading concordance from " + infile); corpus = Corpus.readFromFile(FileUtil.reader(infile)); corpus.printStats(System.out); + corpus1 = Corpus.readFromFile(FileUtil.reader(infile1)); + corpus1.printStats(System.out); } catch (IOException e) { System.err.println("Failed to open input file: " + infile); e.printStackTrace(); System.exit(1); } - if (!options.has("agree")) + if (!(options.has("agree-direction")||options.has("agree-language"))) System.out.println("Running with " + tags + " tags " + "for " + iterations + " iterations " + ((skip > 0) ? "skipping large phrases for first " + skip + " iterations " : "") + @@ -96,8 +103,11 @@ public class Trainer System.out.println(); PhraseCluster cluster = null; - Agree agree = null; - if (options.has("agree")) + Agree2Sides agree2sides = null; + Agree agree= null; + if (options.has("agree-language")) + agree2sides = new Agree2Sides(tags, corpus,corpus1); + else if (options.has("agree-direction")) agree = new Agree(tags, corpus); else { @@ -124,6 +134,9 @@ public class Trainer double o; if (agree != null) o = agree.EM(); + else if(agree2sides!=null){ + o = agree2sides.EM(); + } else { if (i < skip) -- cgit v1.2.3