package phrase; import io.FileUtil; import java.io.PrintStream; import java.util.Arrays; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; public class PhraseCluster { public int K; public double scale; private int n_phrase; private int n_words; public PhraseCorpus c; private ExecutorService pool; /**@brief * emit[tag][position][word] */ private double emit[][][]; private double pi[][]; public static void main(String[] args) { String input_fname = args[0]; int tags = Integer.parseInt(args[1]); String outputDir = args[2]; int iterations = Integer.parseInt(args[3]); double scale = Double.parseDouble(args[4]); int threads = Integer.parseInt(args[5]); PhraseCorpus corpus = new PhraseCorpus(input_fname); PhraseCluster cluster = new PhraseCluster(tags, corpus, scale, threads); PhraseObjective.ps = FileUtil.openOutFile(outputDir + "/phrase_stat.out"); for(int i=0;i 0) pool = Executors.newFixedThreadPool(threads); emit=new double [K][PhraseCorpus.NUM_CONTEXT][n_words]; pi=new double[n_phrase][K]; for(double [][]i:emit){ for(double []j:i){ arr.F.randomise(j); } } for(double []j:pi){ arr.F.randomise(j); } } public void finish() { if (pool != null) pool.shutdown(); } public double EM(){ double [][][]exp_emit=new double [K][PhraseCorpus.NUM_CONTEXT][n_words]; double [][]exp_pi=new double[n_phrase][K]; double loglikelihood=0; //E for(int phrase=0;phrase expectations = new LinkedBlockingQueue(); double [][][]exp_emit=new double [K][PhraseCorpus.NUM_CONTEXT][n_words]; double [][]exp_pi=new double[n_phrase][K]; double loglikelihood=0; double primal=0; //E for(int phrase=0;phrase