for(String [] path:plus)
assert AbstractOracle.USER_ACCEPTED == expected.paths.tracePathPrefixClosed(AbstractLearnerGraph.buildList(Arrays.asList(path),config,getLabelConverter()));
for(String [] path:minus)
assert AbstractOracle.USER_ACCEPTED != expected.paths.tracePathPrefixClosed(AbstractLearnerGraph.buildList(Arrays.asList(path),config,getLabelConverter()));
// Visualiser.getVisualiser()
Learner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,testConfig,null,null))
{
@Override
public LearnerGraph MergeAndDeterminize(LearnerGraph original, StatePair pair)
{
// Check that compatibility score computation gives the same response as if we did merge and computed a difference between the number of states.
ScoreMode origScore = original.config.getLearnerScoreMode();original.config.setLearnerScoreMode(ScoreMode.COMPATIBILITY);
long compatibilityScore = original.pairscores.computePairCompatibilityScore(pair);
original.config.setLearnerScoreMode(origScore);
LearnerGraph outcome = super.MergeAndDeterminize(original, pair);
Assert.assertEquals(compatibilityScore+1,original.getStateNumber()-outcome.getStateNumber());
return outcome;
}
@Override
public Pair<Integer,String> CheckWithEndUser(
@SuppressWarnings("unused") LearnerGraph model,
List<Label> question, @SuppressWarnings("unused") int valueForNoRestart,
@SuppressWarnings("unused") List<Boolean> acceptedElements,
@SuppressWarnings("unused") PairScore pairBeingMerged,
@SuppressWarnings("unused") final Object [] moreOptions)
{
Pair<Integer,String> oracleAnswer = new Pair<Integer,String>(expected.paths.tracePathPrefixClosed(question),null);
return oracleAnswer;
}
};
config.setDebugMode(false);
//l.setPairsMergedPerHypothesis(0);
//l.setGeneralisationThreshold(1);
//l.setCertaintyThreshold(5);
testConfig.setLearnerIdMode(IDMode.POSITIVE_NEGATIVE);
LearnerGraph learntStructureA = new LearnerGraph(l.learnMachine(buildSet(plus,testConfig,getLabelConverter()), buildSet(minus,testConfig,getLabelConverter())),expected.config);
// Now do the same with ptasets instead of real sets
PTASequenceSet plusPTA = new PTASequenceSet();plusPTA.addAll(buildSet(plus,testConfig,getLabelConverter()));PTASequenceSet minusPTA = new PTASequenceSet();minusPTA.addAll(buildSet(minus,testConfig,getLabelConverter()));
LearnerGraph learntStructureB = new LearnerGraph(l.learnMachine(plusPTA, minusPTA),expected.config);
Assert.assertNull(WMethod.checkM(learntStructureA, learntStructureB));
LearnerGraph learntMachineNoRejects = new LearnerGraph(expected.config);
AbstractPathRoutines.removeRejectStates(learntStructureA,learntMachineNoRejects);
Assert.assertNull(WMethod.checkM(learntMachineNoRejects, expected));
}