本文整理汇总了Java中cc.mallet.fst.TokenAccuracyEvaluator.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Java TokenAccuracyEvaluator.evaluate方法的具体用法?Java TokenAccuracyEvaluator.evaluate怎么用?Java TokenAccuracyEvaluator.evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cc.mallet.fst.TokenAccuracyEvaluator
的用法示例。
在下文中一共展示了TokenAccuracyEvaluator.evaluate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: train
import cc.mallet.fst.TokenAccuracyEvaluator; //导入方法依赖的package包/类
public SyllTagModel train(Collection<Alignment> trainInputs, Collection<Alignment> testInputs, boolean eval) {
Pipe pipe = makePipe();
InstanceList trainExamples = makeExamplesFromAlignsWithPipe(trainInputs, pipe);
InstanceList testExamples = null;
if (testInputs != null) {
testExamples = makeExamplesFromAlignsWithPipe(testInputs, pipe);
}
log.info("Training test-time syll aligner on whole data...");
TransducerTrainer trainer = trainOnce(pipe, trainExamples);
if (eval) {
TokenAccuracyEvaluator evaler = new TokenAccuracyEvaluator(trainExamples, "traindata");
evaler.evaluate(trainer);
double trainAcc = evaler.getAccuracy("traindata");
double testAcc = 0.0;
if (testExamples != null) {
TokenAccuracyEvaluator evaler2 = new TokenAccuracyEvaluator(testExamples, "testdata");
evaler2.evaluate(trainer);
testAcc = evaler2.getAccuracy("testdata");
}
log.info("Train data accuracy = " + trainAcc + ", test data accuracy = " + testAcc);
}
return new SyllTagModel((CRF) trainer.getTransducer());
}
示例2: testDualSpaceViewer
import cc.mallet.fst.TokenAccuracyEvaluator; //导入方法依赖的package包/类
public void testDualSpaceViewer () throws IOException
{
Pipe pipe = TestMEMM.makeSpacePredictionPipe ();
String[] data0 = { TestCRF.data[0] };
String[] data1 = TestCRF.data;
InstanceList training = new InstanceList (pipe);
training.addThruPipe (new ArrayIterator (data0));
InstanceList testing = new InstanceList (pipe);
testing.addThruPipe (new ArrayIterator (data1));
CRF crf = new CRF (pipe, null);
crf.addFullyConnectedStatesForLabels ();
CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood (crf);
TokenAccuracyEvaluator eval = new TokenAccuracyEvaluator (new InstanceList[] {training, testing}, new String[] {"Training", "Testing"});
for (int i = 0; i < 5; i++) {
crft.train (training, 1);
eval.evaluate(crft);
}
CRFExtractor extor = hackCrfExtor (crf);
Extraction e1 = extor.extract (new ArrayIterator (data1));
Pipe pipe2 = TestMEMM.makeSpacePredictionPipe ();
InstanceList training2 = new InstanceList (pipe2);
training2.addThruPipe (new ArrayIterator (data0));
InstanceList testing2 = new InstanceList (pipe2);
testing2.addThruPipe (new ArrayIterator (data1));
MEMM memm = new MEMM (pipe2, null);
memm.addFullyConnectedStatesForLabels ();
MEMMTrainer memmt = new MEMMTrainer (memm);
TransducerEvaluator memmeval = new TokenAccuracyEvaluator (new InstanceList[] {training2, testing2}, new String[] {"Training2", "Testing2"});
memmt.train (training2, 5);
memmeval.evaluate(memmt);
CRFExtractor extor2 = hackCrfExtor (memm);
Extraction e2 = extor2.extract (new ArrayIterator (data1));
if (!htmlDir.exists ()) htmlDir.mkdir ();
LatticeViewer.viewDualResults (htmlDir, e1, extor, e2, extor2);
}
示例3: accuracyFor
import cc.mallet.fst.TokenAccuracyEvaluator; //导入方法依赖的package包/类
private double accuracyFor(InstanceList examples) {
TokenAccuracyEvaluator teval = new TokenAccuracyEvaluator(examples, "train");
teval.evaluate(lastTrainer);
return teval.getAccuracy("train");
}
示例4: ignoretestDualSpaceViewer
import cc.mallet.fst.TokenAccuracyEvaluator; //导入方法依赖的package包/类
public void ignoretestDualSpaceViewer () throws IOException
{
Pipe pipe = TestMEMM.makeSpacePredictionPipe ();
String[] data0 = { TestCRF.data[0] };
String[] data1 = TestCRF.data;
InstanceList training = new InstanceList (pipe);
training.addThruPipe (new ArrayIterator (data0));
InstanceList testing = new InstanceList (pipe);
testing.addThruPipe (new ArrayIterator (data1));
CRF crf = new CRF (pipe, null);
crf.addFullyConnectedStatesForLabels ();
CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood (crf);
TokenAccuracyEvaluator eval = new TokenAccuracyEvaluator (new InstanceList[] {training, testing}, new String[] {"Training", "Testing"});
for (int i = 0; i < 5; i++) {
crft.train (training, 1);
eval.evaluate(crft);
}
CRFExtractor extor = hackCrfExtor (crf);
Extraction e1 = extor.extract (new ArrayIterator (data1));
Pipe pipe2 = TestMEMM.makeSpacePredictionPipe ();
InstanceList training2 = new InstanceList (pipe2);
training2.addThruPipe (new ArrayIterator (data0));
InstanceList testing2 = new InstanceList (pipe2);
testing2.addThruPipe (new ArrayIterator (data1));
MEMM memm = new MEMM (pipe2, null);
memm.addFullyConnectedStatesForLabels ();
MEMMTrainer memmt = new MEMMTrainer (memm);
TransducerEvaluator memmeval = new TokenAccuracyEvaluator (new InstanceList[] {training2, testing2}, new String[] {"Training2", "Testing2"});
memmt.train (training2, 5);
memmeval.evaluate(memmt);
CRFExtractor extor2 = hackCrfExtor (memm);
Extraction e2 = extor2.extract (new ArrayIterator (data1));
if (!htmlDir.exists ()) htmlDir.mkdir ();
LatticeViewer.viewDualResults (htmlDir, e1, extor, e2, extor2);
}