summaryrefslogtreecommitdiff
path: root/gi/posterior-regularisation/prjava/src/phrase/PhraseCorpus.java
diff options
context:
space:
mode:
authortrevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-09 16:22:54 +0000
committertrevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-09 16:22:54 +0000
commit808aa98dfdc0f2beb42503172de61f72981d6735 (patch)
treefa8e4c327065e31f6a76e0d4b0f74ceb3c11e511 /gi/posterior-regularisation/prjava/src/phrase/PhraseCorpus.java
parent4b17ba155568a394373f6baba40e8b5d5281ccdb (diff)
Added formal command line options & new main class.
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@200 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'gi/posterior-regularisation/prjava/src/phrase/PhraseCorpus.java')
-rw-r--r--gi/posterior-regularisation/prjava/src/phrase/PhraseCorpus.java17
1 files changed, 12 insertions, 5 deletions
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<String,Integer>();
wordLex=new HashMap<String,Integer>();
@@ -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);