// now sanity checking on the plus and minus sets
for(String [] path:plus)
assert AbstractOracle.USER_ACCEPTED == expected.paths.tracePathPrefixClosed(Arrays.asList(path));
for(String [] path:minus)
assert AbstractOracle.USER_ACCEPTED != expected.paths.tracePathPrefixClosed(Arrays.asList(path));
Learner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,testConfig,null,null))
{
@Override
public Pair<Integer,String> CheckWithEndUser(
@SuppressWarnings("unused") LearnerGraph model,
List<String> question, @SuppressWarnings("unused") int responseForNoRestart,
@SuppressWarnings("unused") List<Boolean> acceptedElements,
@SuppressWarnings("unused") final Object [] moreOptions)
{
return new Pair<Integer,String>(expected.paths.tracePathPrefixClosed(question),null);
}
};
testConfig.setLearnerIdMode(IDMode.POSITIVE_NEGATIVE);
ByteArrayOutputStream logStream = new ByteArrayOutputStream();
RecordProgressDecorator recorder = new RecordProgressDecorator(l,logStream,1,testConfig,useZip);
Collection<List<String>> testSet = new LinkedList<List<String>>();
recorder.writeLearnerEvaluationData(new LearnerEvaluationConfiguration(expected, testSet, testConfig, null, 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 = new LearnerGraph(testConfig);
AbstractPathRoutines.removeRejectStates(learntStructureA,learntMachineNoRejects);
Assert.assertNull(WMethod.checkM(learntMachineNoRejects, expected));
switch(kind)
{
case RECORDERTEST_SS:
{// 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();
Assert.assertNull(WMethod.checkM(expected, eval1.graph));
Assert.assertEquals(testSet, eval1.testSet);
Assert.assertEquals(expected.config, testConfig);
LearnerEvaluationConfiguration eval2 = simulator2.readLearnerConstructionData();
Assert.assertNull(WMethod.checkM(expected, eval2.graph));
Assert.assertEquals(testSet, eval2.testSet);
Assert.assertEquals(expected.config, testConfig);
new Test_LearnerComparator(simulator,simulator2,true).learnMachine(buildSet(plus), buildSet(minus));
break;
}
case RECORDERTEST_SL:
{// now a simulator to a learner
final LearnerSimulator simulator = new LearnerSimulator(new ByteArrayInputStream(logStream.toByteArray()),useZip);
LearnerEvaluationConfiguration eval1 = simulator.readLearnerConstructionData();
Assert.assertNull(WMethod.checkM(expected, eval1.graph));
Assert.assertEquals(testSet, eval1.testSet);
Assert.assertEquals(expected.config, testConfig);
Learner learner2 = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,expected.config,null,null))
{
@Override
public Pair<Integer,String> CheckWithEndUser(
@SuppressWarnings("unused") LearnerGraph model,
List<String> question, @SuppressWarnings("unused") int responseForNoRestart,
@SuppressWarnings("unused") List<Boolean> acceptedElements,
@SuppressWarnings("unused") final Object [] moreOptions)
{
return new Pair<Integer,String>(expected.paths.tracePathPrefixClosed(question),null);
}
};
new Test_LearnerComparator(learner2,simulator,true).learnMachine(buildSet(plus), buildSet(minus));
break;
}
case RECORDERTEST_LL:
{// now two learners
Learner learnerA = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,testConfig,null,null))
{
@Override
public Pair<Integer,String> CheckWithEndUser(
@SuppressWarnings("unused") LearnerGraph model,
List<String> question, @SuppressWarnings("unused") int responseForNoRestart,
@SuppressWarnings("unused") List<Boolean> acceptedElements,
@SuppressWarnings("unused") final Object [] moreOptions)
{
return new Pair<Integer,String>(expected.paths.tracePathPrefixClosed(question),null);
}
};
Learner learnerB = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,testConfig,null,null))
{
@Override
public Pair<Integer,String> CheckWithEndUser(
@SuppressWarnings("unused") LearnerGraph model,
List<String> question, @SuppressWarnings("unused") int responseForNoRestart,