From 808aa98dfdc0f2beb42503172de61f72981d6735 Mon Sep 17 00:00:00 2001 From: "trevor.cohn" Date: Fri, 9 Jul 2010 16:22:54 +0000 Subject: Added formal command line options & new main class. git-svn-id: https://ws10smt.googlecode.com/svn/trunk@200 ec762483-ff6d-05da-a07a-a48fb63a330f --- .../prjava/src/phrase/PhraseCorpus.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'gi/posterior-regularisation/prjava/src/phrase/PhraseCorpus.java') diff --git a/gi/posterior-regularisation/prjava/src/phrase/PhraseCorpus.java b/gi/posterior-regularisation/prjava/src/phrase/PhraseCorpus.java index 11e948ff..903e47c8 100644 --- a/gi/posterior-regularisation/prjava/src/phrase/PhraseCorpus.java +++ b/gi/posterior-regularisation/prjava/src/phrase/PhraseCorpus.java @@ -1,7 +1,11 @@ package phrase; +import io.FileUtil; + import java.io.BufferedInputStream; import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintStream; import java.util.ArrayList; @@ -20,8 +24,9 @@ public class PhraseCorpus public int data[][][]; public int numContexts; - public PhraseCorpus(String filename){ - BufferedReader r=io.FileUtil.openBufferedReader(filename); + public PhraseCorpus(String filename) throws FileNotFoundException, IOException + { + BufferedReader r = FileUtil.reader(new File(filename)); phraseLex=new HashMap(); wordLex=new HashMap(); @@ -84,8 +89,9 @@ public class PhraseCorpus } //for debugging - public void saveLex(String lexFilename){ - PrintStream ps=io.FileUtil.openOutFile(lexFilename); + public void saveLex(String lexFilename) throws FileNotFoundException, IOException + { + PrintStream ps = FileUtil.printstream(new File(lexFilename)); ps.println("Phrase Lexicon"); ps.println(phraseLex.size()); printDict(phraseLex,ps); @@ -175,7 +181,8 @@ public class PhraseCorpus return null; } - public static void main(String[] args) { + public static void main(String[] args) throws Exception + { String LEX_FILENAME="../pdata/lex.out"; String DATA_FILENAME="../pdata/btec.con"; PhraseCorpus c=new PhraseCorpus(DATA_FILENAME); -- cgit v1.2.3