diff options
author | trevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-09 16:42:01 +0000 |
---|---|---|
committer | trevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-09 16:42:01 +0000 |
commit | 0d1d84630a08f1c901cf09b4bcc9356c4165302f (patch) | |
tree | 934647a40407956f541d640deb893b72ff75d3a8 | |
parent | 6a862cec42c8197919e3ef1250c58ac2b4260e10 (diff) |
Make
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@203 ec762483-ff6d-05da-a07a-a48fb63a330f
-rw-r--r-- | gi/posterior-regularisation/prjava/Makefile | 5 | ||||
-rw-r--r-- | gi/posterior-regularisation/prjava/build.xml | 2 | ||||
-rw-r--r-- | gi/posterior-regularisation/prjava/lib/jopt-simple-3.2.jar | bin | 0 -> 53244 bytes | |||
-rw-r--r-- | gi/posterior-regularisation/prjava/src/hmm/HMM.java | 7 | ||||
-rw-r--r-- | gi/posterior-regularisation/prjava/src/hmm/POS.java | 21 | ||||
-rw-r--r-- | gi/posterior-regularisation/prjava/src/test/HMMModelStats.java | 11 |
6 files changed, 35 insertions, 11 deletions
diff --git a/gi/posterior-regularisation/prjava/Makefile b/gi/posterior-regularisation/prjava/Makefile new file mode 100644 index 00000000..abd9b964 --- /dev/null +++ b/gi/posterior-regularisation/prjava/Makefile @@ -0,0 +1,5 @@ +all: + ant + +clean: + ant clean diff --git a/gi/posterior-regularisation/prjava/build.xml b/gi/posterior-regularisation/prjava/build.xml index 40199144..97569bef 100644 --- a/gi/posterior-regularisation/prjava/build.xml +++ b/gi/posterior-regularisation/prjava/build.xml @@ -32,8 +32,6 @@ <target name="clean" description="clean up" > - <!-- Delete the ${build} and ${dist} directory trees --> <delete dir="${build}"/> - <delete dir="${dist}"/> </target> </project> diff --git a/gi/posterior-regularisation/prjava/lib/jopt-simple-3.2.jar b/gi/posterior-regularisation/prjava/lib/jopt-simple-3.2.jar Binary files differnew file mode 100644 index 00000000..56373621 --- /dev/null +++ b/gi/posterior-regularisation/prjava/lib/jopt-simple-3.2.jar diff --git a/gi/posterior-regularisation/prjava/src/hmm/HMM.java b/gi/posterior-regularisation/prjava/src/hmm/HMM.java index 1c4d7659..17a4679f 100644 --- a/gi/posterior-regularisation/prjava/src/hmm/HMM.java +++ b/gi/posterior-regularisation/prjava/src/hmm/HMM.java @@ -1,5 +1,8 @@ package hmm;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Scanner;
@@ -248,8 +251,8 @@ public class HMM { }
}
- public void writeModel(String modelFilename){
- PrintStream ps=io.FileUtil.openOutFile(modelFilename);
+ public void writeModel(String modelFilename) throws FileNotFoundException, IOException{
+ PrintStream ps=io.FileUtil.printstream(new File(modelFilename));
ps.println(trans.length);
ps.println("Initial Probabilities:");
for(int i=0;i<pi.length;i++){
diff --git a/gi/posterior-regularisation/prjava/src/hmm/POS.java b/gi/posterior-regularisation/prjava/src/hmm/POS.java index 2dcf271c..bdcbc683 100644 --- a/gi/posterior-regularisation/prjava/src/hmm/POS.java +++ b/gi/posterior-regularisation/prjava/src/hmm/POS.java @@ -1,5 +1,8 @@ package hmm;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
import java.io.PrintStream;
import java.util.HashMap;
@@ -23,11 +26,17 @@ public class POS { public static void main(String[] args) {
//POS p=new POS();
//POS p=new POS(true);
- PRPOS();
+ try {
+ PRPOS();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
- public POS(){
+ public POS() throws FileNotFoundException, IOException{
Corpus c= new Corpus(trainFilename);
//size of vocabulary +1 for unknown tokens
HMM hmm =new HMM(N_STATE, c.getVocabSize()+1,c.getAllData());
@@ -43,7 +52,7 @@ public class POS { Corpus test=new Corpus(testFilename,c.vocab);
- PrintStream ps= io.FileUtil.openOutFile(predFilename);
+ PrintStream ps= io.FileUtil.printstream(new File(predFilename));
int [][]data=test.getAllData();
for(int i=0;i<data.length;i++){
@@ -58,7 +67,7 @@ public class POS { }
//POS induction with L1/Linf constraints
- public static void PRPOS(){
+ public static void PRPOS() throws FileNotFoundException, IOException{
Corpus c= new Corpus(trainFilename);
//size of vocabulary +1 for unknown tokens
HMM hmm =new HMM(N_STATE, c.getVocabSize()+1,c.getAllData());
@@ -75,7 +84,7 @@ public class POS { }
- public POS(boolean supervised){
+ public POS(boolean supervised) throws FileNotFoundException, IOException{
Corpus c= new Corpus(trainFilename);
//size of vocabulary +1 for unknown tokens
HMM hmm =new HMM(c.tagVocab.size() , c.getVocabSize()+1,c.getAllData());
@@ -95,7 +104,7 @@ public class POS { System.out.println(c.vocab.get("<e>"));
- PrintStream ps= io.FileUtil.openOutFile(predFilename);
+ PrintStream ps= io.FileUtil.printstream(new File(predFilename));
int [][]data=test.getAllData();
for(int i=0;i<data.length;i++){
diff --git a/gi/posterior-regularisation/prjava/src/test/HMMModelStats.java b/gi/posterior-regularisation/prjava/src/test/HMMModelStats.java index dbf517fd..d54525c8 100644 --- a/gi/posterior-regularisation/prjava/src/test/HMMModelStats.java +++ b/gi/posterior-regularisation/prjava/src/test/HMMModelStats.java @@ -3,6 +3,9 @@ package test; import hmm.HMM;
import hmm.POS;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
@@ -39,7 +42,13 @@ public class HMMModelStats { - PrintStream ps=io.FileUtil.openOutFile(statsFilename);
+ PrintStream ps = null;
+ try {
+ ps = io.FileUtil.printstream(new File(statsFilename));
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
double [][] emit=hmm.getEmitProb();
for(int i=0;i<emit.length;i++){
|