public LabelAlphabet getTargetAlphabet () { return (LabelAlphabet) crf.getOutputAlphabet (); }
public LabelAlphabet getTargetAlphabet () { return (LabelAlphabet) crf.getOutputAlphabet (); }
public LabelAlphabet getTargetAlphabet () { return (LabelAlphabet) crf.getOutputAlphabet (); }
public CRFTrainerByGE(CRF crf, ArrayList<GEConstraint> constraints, int numThreads) { this.converged = false; this.iteration = 0; this.constraints = constraints; this.crf = crf; this.numThreads = numThreads; this.numResets = DEFAULT_NUM_RESETS; this.gaussianPriorVariance = DEFAULT_GPV; // default one to one state label map // other maps can be set with setStateLabelMap this.stateLabelMap = new StateLabelMap(crf.getOutputAlphabet(),true); }
public CRFTrainerByGE(CRF crf, ArrayList<GEConstraint> constraints, int numThreads) { this.converged = false; this.iteration = 0; this.constraints = constraints; this.crf = crf; this.numThreads = numThreads; this.numResets = DEFAULT_NUM_RESETS; this.gaussianPriorVariance = DEFAULT_GPV; // default one to one state label map // other maps can be set with setStateLabelMap this.stateLabelMap = new StateLabelMap(crf.getOutputAlphabet(),true); }
public CRFTrainerByPR(CRF crf, ArrayList<PRConstraint> constraints, int numThreads) { this.crf = crf; this.iter = 0; this.value = Double.NEGATIVE_INFINITY; this.constraints = constraints; this.pGpv = 10; this.tolerance = 0.001; this.numThreads = numThreads; this.stateLabelMap = new StateLabelMap(crf.getOutputAlphabet(),true); }
public CRFTrainerByPR(CRF crf, ArrayList<PRConstraint> constraints, int numThreads) { this.crf = crf; this.iter = 0; this.value = Double.NEGATIVE_INFINITY; this.constraints = constraints; this.pGpv = 10; this.tolerance = 0.001; this.numThreads = numThreads; this.stateLabelMap = new StateLabelMap(crf.getOutputAlphabet(),true); }
public CRFTrainerByGE(CRF crf, ArrayList<GEConstraint> constraints, int numThreads) { this.converged = false; this.iteration = 0; this.constraints = constraints; this.crf = crf; this.numThreads = numThreads; this.numResets = DEFAULT_NUM_RESETS; this.gaussianPriorVariance = DEFAULT_GPV; // default one to one state label map // other maps can be set with setStateLabelMap this.stateLabelMap = new StateLabelMap(crf.getOutputAlphabet(),true); }
public CRFTrainerByPR(CRF crf, ArrayList<PRConstraint> constraints, int numThreads) { this.crf = crf; this.iter = 0; this.value = Double.NEGATIVE_INFINITY; this.constraints = constraints; this.pGpv = 10; this.tolerance = 0.001; this.numThreads = numThreads; this.stateLabelMap = new StateLabelMap(crf.getOutputAlphabet(),true); }
public void trainFor(Collection<Alignment> inputs) { // this pipe is the default pipe with new alphabet Stopwatch watch = Stopwatch.createStarted(); trainRound(inputs, new Alphabet(), 0); crf.getInputAlphabet().stopGrowth(); crf.getOutputAlphabet().stopGrowth(); watch.stop(); log.info("Training took " + watch); }
private void setupClassifier(String trainingdata) { try { crf_input = new ObjectInputStream(ResourceUtils.loadResource( trainingdata, this.getClass())); crf = (CRF) crf_input.readObject(); crf_input.close(); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } crf.getInputAlphabet().stopGrowth(); crf.getOutputAlphabet().stopGrowth(); crf_pipe = crf.getInputPipe(); crf_pipe.setTargetProcessing(false); crf_estimator = new ViterbiConfidenceEstimator(crf); }
/** * prints out the tagset used in the model 'modelFile' */ public static void printOutputAlphabet(final File modelFile) { Object model; final NETagger tagger = new NETagger(); try { tagger.readModel(modelFile); } catch (final FileNotFoundException e) { e.printStackTrace(); } catch (final IOException e) { e.printStackTrace(); } catch (final ClassNotFoundException e) { e.printStackTrace(); } model = tagger.getModel(); final Alphabet alpha = ((CRF) model).getOutputAlphabet(); final Object modelLabels[] = alpha.toArray(); for (final Object modelLabel : modelLabels) System.out.println(modelLabel); } }
private void setupClassifier(String trainingdata) { try { crf_input = new ObjectInputStream(ResourceUtils.loadResource( trainingdata, this.getClass())); crf = (CRF) crf_input.readObject(); crf_input.close(); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } crf.getInputAlphabet().stopGrowth(); crf.getOutputAlphabet().stopGrowth(); crf_pipe = crf.getInputPipe(); crf_pipe.setTargetProcessing(false); crf_estimator = new ViterbiConfidenceEstimator(crf); }
/** * prints out the tagset used in the model 'modelFile' * * @throws IOException * @throws ClassNotFoundException * @throws FileNotFoundException */ public static void printTagset(final File modelFile) throws FileNotFoundException, ClassNotFoundException, IOException { Object model; final POSTagger tagger = POSTagger.readModel(modelFile); model = tagger.getModel(); final Alphabet alpha = ((CRF) model).getOutputAlphabet(); final Object modelLabels[] = alpha.toArray(); for (final Object modelLabel : modelLabels) System.out.println(modelLabel); } }
int j = 0; if (model != null) { Alphabet alpha = model.getOutputAlphabet(); Object modelLabels[] = alpha.toArray();
private TransducerTrainer trainOnce(Pipe pipe, InstanceList trainData) { Stopwatch watch = Stopwatch.createStarted(); CRF crf = new CRF(pipe, null); crf.addOrderNStates(trainData, new int[]{1}, null, null, null, null, false); crf.addStartState(); log.info("Starting alignTag training..."); CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(crf, 8); trainer.setGaussianPriorVariance(2); // trainer.setUseSomeUnsupportedTrick(false); trainer.train(trainData); trainer.shutdown(); watch.stop(); log.info("Align Tag CRF Training took " + watch.toString()); crf.getInputAlphabet().stopGrowth(); crf.getOutputAlphabet().stopGrowth(); return trainer; }
private TransducerTrainer trainOnce(Pipe pipe, InstanceList examples) { Stopwatch watch = Stopwatch.createStarted(); CRF crf = new CRF(pipe, null); crf.addOrderNStates(examples, new int[]{1}, null, null, null, null, false); crf.addStartState(); // crf.setWeightsDimensionAsIn(examples, false); log.info("Starting syllchain training..."); CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(crf, 8); trainer.setGaussianPriorVariance(2); // trainer.setUseSomeUnsupportedTrick(false); // trainer.setAddNoFactors(true); trainer.train(examples); trainer.shutdown(); watch.stop(); log.info("SyllChain CRF Training took " + watch.toString()); crf.getInputAlphabet().stopGrowth(); crf.getOutputAlphabet().stopGrowth(); return trainer; }
private TransducerTrainer trainOnce(Pipe pipe, InstanceList examples) { Stopwatch watch = Stopwatch.createStarted(); CRF crf = new CRF(pipe, null); crf.addOrderNStates(examples, new int[]{1}, null, null, null, null, false); crf.addStartState(); crf.setWeightsDimensionAsIn(examples, true); if (initFrom != null) { crf.initializeApplicableParametersFrom(initFrom); } log.info("Starting syllchain training..."); CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(crf, 8); trainer.setGaussianPriorVariance(2); trainer.setAddNoFactors(true); // trainer.setUseSomeUnsupportedTrick(true); trainer.train(examples); trainer.shutdown(); watch.stop(); log.info("SyllChain CRF Training took " + watch.toString()); crf.getInputAlphabet().stopGrowth(); crf.getOutputAlphabet().stopGrowth(); return trainer; }
private TransducerTrainer trainOnce(Pipe pipe, InstanceList trainData) { Stopwatch watch = Stopwatch.createStarted(); CRF crf = new CRF(pipe, null); crf.addOrderNStates(trainData, new int[]{1}, null, null, null, null, false); crf.addStartState(); crf.setWeightsDimensionAsIn(trainData, false); if (initFrom != null) { crf.initializeApplicableParametersFrom(initFrom); } log.info("Starting alignTag training..."); CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(crf, 8); trainer.setGaussianPriorVariance(2); trainer.setAddNoFactors(true); trainer.setUseSomeUnsupportedTrick(false); trainer.train(trainData); trainer.shutdown(); watch.stop(); log.info("Syll align Tag CRF Training took " + watch.toString()); crf.getInputAlphabet().stopGrowth(); crf.getOutputAlphabet().stopGrowth(); return trainer; }
new FeatureVector(crf.getInputAlphabet(), new int[] { 1, 2, 3 }), }); FeatureSequence ss = new FeatureSequence(crf.getOutputAlphabet(), new int[] { 0, 1, 2, 3 }); InstanceList ilist = new InstanceList(new Noop(inputAlphabet,