protected void checkLearner(String fsmString, String [][] plus, String [][] minus)
{
final DirectedSparseGraph g = TestFSMAlgo.buildGraph(fsmString, "sample FSM");
final DirectedSparseGraph completedGraph = (DirectedSparseGraph)g.copy();TestFSMAlgo.completeGraph(completedGraph, "REJECT");
final FSMStructure expected = WMethod.getGraphData(g);
//updateFrame(g, g);
// now sanity checking on the plus and minus sets
for(String [] path:plus)
assert RPNIBlueFringeLearner.USER_ACCEPTED == WMethod.tracePath(expected, Arrays.asList(path));
for(String [] path:minus)
assert RPNIBlueFringeLearner.USER_ACCEPTED != WMethod.tracePath(expected, Arrays.asList(path));
RPNIBlueFringeLearnerTestComponentOpt l = new RPNIBlueFringeLearnerTestComponentOpt(visFrame)
{
@Override
protected int checkWithEndUser(DirectedSparseGraph model,List<String> question, final Object [] moreOptions)
{
return checkPath(expected, g, question, moreOptions);
}
};
l.setDebugMode(false);
//l.setPairsMergedPerHypothesis(0);
//l.setGeneralisationThreshold(1);
//l.setCertaintyThreshold(5);
if (visFrame != null) l.addObserver(visFrame);
l.getScoreComputer().setMode(IDMode.POSITIVE_NEGATIVE);
l.init(buildSet(plus), buildSet(minus));
DirectedSparseGraph learningOutcomeA = l.learnMachine();
//updateFrame(learningOutcome,g);
FSMStructure learntStructureA = WMethod.getGraphData(learningOutcomeA);
// Now do the same with ptasets instead of real sets
PTASequenceSet plusPTA = new PTASequenceSet();plusPTA.addAll(buildSet(plus));PTASequenceSet minusPTA = new PTASequenceSet();minusPTA.addAll(buildSet(minus));
l.init(plusPTA, minusPTA);
DirectedSparseGraph learningOutcomeB = l.learnMachine();
FSMStructure learntStructureB = WMethod.getGraphData(learningOutcomeB);
TestFSMAlgo.checkMBoolean(learntStructureA, learntStructureB, learntStructureA.init, learntStructureB.init);
//TestFSMAlgo.checkM(learntStructure,completedGraph,learntStructure.init,expected.init);
}