summaryrefslogtreecommitdiff
path: root/gi/posterior-regularisation/prjava/src/hmm
diff options
context:
space:
mode:
authortrevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-09 16:42:01 +0000
committertrevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-09 16:42:01 +0000
commit4e37402323c3227e90a89345387834e149732b5c (patch)
treed1ae6cc41076de10aa1d26b4f57d4c209877a5b8 /gi/posterior-regularisation/prjava/src/hmm
parenta5cbf679c4a78818e07fc7756d5e466450a5be15 (diff)
Make
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@203 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'gi/posterior-regularisation/prjava/src/hmm')
-rw-r--r--gi/posterior-regularisation/prjava/src/hmm/HMM.java7
-rw-r--r--gi/posterior-regularisation/prjava/src/hmm/POS.java21
2 files changed, 20 insertions, 8 deletions
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++){