* @param minus negatives.
* @param useZip whether to use ZIP compression with the data stream.
*/
protected void checkLearnerProgressRecording(String fsmString, String name, final String [][] plus, final String [][] minus)
{
Configuration testConfig = Configuration.getDefaultConfiguration().copy();
testConfig.setGdFailOnDuplicateNames(false);
if (forceGDfallback) testConfig.setGdMaxNumberOfStatesInCrossProduct(0);
testConfig.setCompressLogs(useCompression);
final DirectedSparseGraph g = FsmParser.buildGraph(fsmString, name);
final LearnerGraph expected = new LearnerGraph(g,testConfig);
// 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));