本文整理汇总了Java中cc.mallet.grmm.learning.ACRFTrainer类的典型用法代码示例。如果您正苦于以下问题:Java ACRFTrainer类的具体用法?Java ACRFTrainer怎么用?Java ACRFTrainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ACRFTrainer类属于cc.mallet.grmm.learning包,在下文中一共展示了ACRFTrainer类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: train
import cc.mallet.grmm.learning.ACRFTrainer; //导入依赖的package包/类
public void train(Collection<Alignment> examples) {
Pipe pipe = makePipe();
InstanceList instances = makeExamplesFromAligns(examples, pipe);
ACRF.Template[] tmpls = new ACRF.Template[]{
new ACRF.BigramTemplate(0)
// new ACRF.BigramTemplate (1),
// new ACRF.PairwiseFactorTemplate (0,1),
// new CrossTemplate1(0,1)
};
ACRF acrf = new ACRF(pipe, tmpls);
ACRFTrainer trainer = new DefaultAcrfTrainer();
acrf.setSupportedOnly(true);
acrf.setGaussianPriorVariance(2.0);
DefaultAcrfTrainer.LogEvaluator eval = new DefaultAcrfTrainer.LogEvaluator();
eval.setNumIterToSkip(2);
trainer.train(acrf, instances, null, null, eval, 9999);
}
示例2: train
import cc.mallet.grmm.learning.ACRFTrainer; //导入依赖的package包/类
public void train(Collection<Alignment> examples) {
Pipe pipe = makePipe();
InstanceList instances = makeExamplesFromAligns(examples, pipe);
ACRF.Template[] tmpls = new ACRF.Template[]{
new ACRF.BigramTemplate(0),
new ACRF.BigramTemplate (1),
new ACRF.PairwiseFactorTemplate (0,1),
new CrossTemplate1(0,1)
};
ACRF acrf = new ACRF(pipe, tmpls);
ACRFTrainer trainer = new DefaultAcrfTrainer();
acrf.setSupportedOnly(true);
acrf.setGaussianPriorVariance(2.0);
DefaultAcrfTrainer.LogEvaluator eval = new DefaultAcrfTrainer.LogEvaluator();
eval.setNumIterToSkip(2);
trainer.train(acrf, instances, null, null, eval, 9999);
}
示例3: main
import cc.mallet.grmm.learning.ACRFTrainer; //导入依赖的package包/类
public static void main (String[] args) throws FileNotFoundException
{
File trainFile = new File (args[0]);
File testFile = new File (args[1]);
File crfFile = new File (args[2]);
Pipe pipe = new SerialPipes (new Pipe[] {
new GenericAcrfData2TokenSequence (2),
new TokenSequence2FeatureVectorSequence (true, true),
});
InstanceList training = new InstanceList (pipe);
training.addThruPipe (new LineGroupIterator (new FileReader (trainFile),
Pattern.compile ("\\s*"),
true));
InstanceList testing = new InstanceList (pipe);
testing.addThruPipe (new LineGroupIterator (new FileReader (testFile),
Pattern.compile ("\\s*"),
true));
ACRF.Template[] tmpls = new ACRF.Template[] {
new ACRF.BigramTemplate (0),
new ACRF.BigramTemplate (1),
new ACRF.PairwiseFactorTemplate (0,1),
new CrossTemplate1 (0,1)
};
ACRF acrf = new ACRF (pipe, tmpls);
ACRFTrainer trainer = new DefaultAcrfTrainer ();
trainer.train (acrf, training, null, testing, 99999);
FileUtils.writeGzippedObject (crfFile, acrf);
}
示例4: main
import cc.mallet.grmm.learning.ACRFTrainer; //导入依赖的package包/类
public static void main (String[] args) throws FileNotFoundException
{
File trainFile = new File (args[0]);
File testFile = new File (args[1]);
File crfFile = new File (args[2]);
Pipe pipe = new SerialPipes (new Pipe[] {
new GenericAcrfData2TokenSequence (2),
new TokenSequence2FeatureVectorSequence (true, true),
});
InstanceList training = new InstanceList (pipe);
training.addThruPipe (new LineGroupIterator (new FileReader (trainFile),
Pattern.compile ("\\s*"),
true));
InstanceList testing = new InstanceList (pipe);
training.addThruPipe (new LineGroupIterator (new FileReader (testFile),
Pattern.compile ("\\s*"),
true));
ACRF.Template[] tmpls = new ACRF.Template[] {
new ACRF.BigramTemplate (0),
new ACRF.BigramTemplate (1),
new ACRF.PairwiseFactorTemplate (0,1),
new CrossTemplate1 (0,1)
};
ACRF acrf = new ACRF (pipe, tmpls);
ACRFTrainer trainer = new DefaultAcrfTrainer ();
trainer.train (acrf, training, null, testing, 99999);
FileUtils.writeGzippedObject (crfFile, acrf);
}