// now sanity checking on the plus and minus sets
for(String [] path:plus)
assert RPNIBlueFringeLearner.USER_ACCEPTED == expected.paths.tracePath(Arrays.asList(path));
for(String [] path:minus)
assert RPNIBlueFringeLearner.USER_ACCEPTED != expected.paths.tracePath(Arrays.asList(path));
RPNIBlueFringeLearner l = new RPNIBlueFringeLearnerTestComponentOpt(null,testConfig)
{
@Override
public Pair<Integer,String> checkWithEndUser(
@SuppressWarnings("unused") LearnerGraph model,
List<String> question,
@SuppressWarnings("unused") final Object [] moreOptions)
{
return new Pair<Integer,String>(expected.paths.tracePath(question),null);
}
};
testConfig.setLearnerIdMode(IDMode.POSITIVE_NEGATIVE);
ByteArrayOutputStream logStream = new ByteArrayOutputStream();
RecordProgressDecorator recorder = new RecordProgressDecorator(l.getLearner(),logStream,1,testConfig,useZip);
Collection<List<String>> testSet = new LinkedList<List<String>>();
recorder.writeLearnerEvaluationData(new ProgressDecorator.LearnerEvaluationConfiguration(expected, testSet, testConfig, null));
LearnerGraph learntStructureA = recorder.learnMachine(buildSet(plus), buildSet(minus));
//System.out.println("compression rate: "+recorder.getCompressionRate());
//System.out.println(logStream.toString()+"============");
//System.out.println(logStream.toByteArray().length);
LearnerGraph learntMachineNoRejects = Transform322.removeRejectStates(learntStructureA,testConfig);
WMethod.checkM(learntMachineNoRejects, expected);
{// matching two simulators
final LearnerSimulator
simulator = new LearnerSimulator(new ByteArrayInputStream(logStream.toByteArray()),useZip),
simulator2 = new LearnerSimulator(new ByteArrayInputStream(logStream.toByteArray()),useZip);
LearnerEvaluationConfiguration eval1 = simulator.readLearnerConstructionData();
WMethod.checkM(expected, eval1.graph);
Assert.assertEquals(testSet, eval1.testSet);
Assert.assertEquals(expected.config, testConfig);
LearnerEvaluationConfiguration eval2 = simulator2.readLearnerConstructionData();
WMethod.checkM(expected, eval2.graph);
Assert.assertEquals(testSet, eval2.testSet);
Assert.assertEquals(expected.config, testConfig);
new Test_LearnerComparator(simulator,simulator2).learnMachine(buildSet(plus), buildSet(minus));
}
{// now a simulator to a learner
final LearnerSimulator simulator = new LearnerSimulator(new ByteArrayInputStream(logStream.toByteArray()),useZip);
LearnerEvaluationConfiguration eval1 = simulator.readLearnerConstructionData();
WMethod.checkM(expected, eval1.graph);
Assert.assertEquals(testSet, eval1.testSet);
Assert.assertEquals(expected.config, testConfig);
RPNIBlueFringeLearner learner2 = new RPNIBlueFringeLearnerTestComponentOpt(null,expected.config)
{
@Override
public Pair<Integer,String> checkWithEndUser(
@SuppressWarnings("unused") LearnerGraph model,
List<String> question,
@SuppressWarnings("unused") final Object [] moreOptions)
{
return new Pair<Integer,String>(expected.paths.tracePath(question),null);
}
};
new Test_LearnerComparator(learner2.getLearner(),simulator).learnMachine(buildSet(plus), buildSet(minus));
}
{// now two learners
RPNIBlueFringeLearner learnerA = new RPNIBlueFringeLearnerTestComponentOpt(null,testConfig)
{
@Override
public Pair<Integer,String> checkWithEndUser(
@SuppressWarnings("unused") LearnerGraph model,
List<String> question,
@SuppressWarnings("unused") final Object [] moreOptions)
{
return new Pair<Integer,String>(expected.paths.tracePath(question),null);
}
};
RPNIBlueFringeLearner learnerB = new RPNIBlueFringeLearnerTestComponentOpt(null,testConfig)
{
@Override
public Pair<Integer,String> checkWithEndUser(
@SuppressWarnings("unused") LearnerGraph model,
List<String> question,
@SuppressWarnings("unused") final Object [] moreOptions)
{
return new Pair<Integer,String>(expected.paths.tracePath(question),null);
}
};
new Test_LearnerComparator(learnerA.getLearner(),learnerB.getLearner()).learnMachine(buildSet(plus), buildSet(minus));
}
}