* @param expectedPTA a textual representation of a PTA which should be built.
* @param expectMaxAutomataToBeTheSameAsPTA whether we expect augmentation of a maximal automaton to yield the same result as that of a normal PTA.
*/
private void checkPTAconstruction(String[][] arrayPlusStrings,String [][] arrayMinusStrings, String expectedPTA, boolean expectMaxAutomataToBeTheSameAsPTA)
{
Configuration conf = mainConfiguration.copy();
Set<List<Label>> plusStrings = buildSet(arrayPlusStrings,conf,converter), minusStrings = buildSet(arrayMinusStrings,conf,converter);
LearnerGraph actualA = null, actualC =null, actualD = null, actualE = null, actualF = null;
IllegalArgumentException eA = null, eC = null, eD = null, eE = null, eF = null;
try
{
actualA = new LearnerGraph(Test_Orig_RPNIBlueFringeLearner.createAugmentedPTA(plusStrings, minusStrings),conf);
}
catch(IllegalArgumentException e)
{
// ignore this - it might be expected.
eA = e;
}
try
{
Configuration config = mainConfiguration.copy();
RPNIUniversalLearner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,config,null,null));
config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
l.init(plusStrings, minusStrings);
actualC = l.getTentativeAutomaton();
}
catch(IllegalArgumentException e)
{
// ignore this - it might be expected.
eC = e;
}
try
{
Configuration config = mainConfiguration.copy();
RPNIUniversalLearner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,config,null,null));
config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
PTASequenceEngine engine = buildPTA(plusStrings, minusStrings);
checkPTAConsistency(engine, plusStrings, true);if (engine.numberOfLeafNodes()>0) checkPTAConsistency(engine, minusStrings, false);
l.init(engine,0,0);
actualD = l.getTentativeAutomaton();
}
catch(IllegalArgumentException e)
{
// ignore this - it might be expected.
eD = e;
}
try
{
Configuration config = mainConfiguration.copy();
RPNIUniversalLearner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,config,null,null));
config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
l.init(buildPTA(plusStrings, buildSet(new String[][] {},config,converter)),0,0);
for(List<Label> seq:minusStrings)
{ Set<List<Label>> negativeSeq = new HashSet<List<Label>>();negativeSeq.add(seq);
l.getTentativeAutomaton().paths.augmentPTA(buildPTA(buildSet(new String[][] {},config,converter),negativeSeq));
}
actualE = l.getTentativeAutomaton();
}
catch(IllegalArgumentException e)
{
// ignore this - it might be expected.
eE = e;
}
try
{
Configuration config = mainConfiguration.copy();
RPNIUniversalLearner l = new RPNIUniversalLearner(null,new LearnerEvaluationConfiguration(null,null,config,null,null));
config.setLearnerIdMode(Configuration.IDMode.POSITIVE_NEGATIVE);
l.getTentativeAutomaton().initPTA();
l.getTentativeAutomaton().paths.augmentPTA(minusStrings, false,true);
l.getTentativeAutomaton().paths.augmentPTA(plusStrings, true,true);
actualF = l.getTentativeAutomaton();
}
catch(IllegalArgumentException e)
{
// ignore this - it might be expected.
eF = e;
}
if (eA != null)
{
Assert.assertNotNull(eC);
Assert.assertNotNull(eD);
Assert.assertNotNull(eE);
if (expectMaxAutomataToBeTheSameAsPTA) Assert.assertNotNull(eF);
throw eA;
}
Assert.assertNull(eA);
Assert.assertNull(eC);
Assert.assertNull(eD);
Assert.assertNull(eE);
if (expectMaxAutomataToBeTheSameAsPTA) Assert.assertNull(eF);
Configuration config = mainConfiguration.copy();
config.setAllowedToCloneNonCmpVertex(true);
checkM(expectedPTA,actualA, config,converter);
checkM(expectedPTA,actualC, config,converter);checkDepthLabelling(actualC);
//Visualiser.updateFrame(actualE,FsmParser.buildGraph(expectedPTA,"expected graph"));Visualiser.waitForKey();
checkM(expectedPTA,actualD,config,converter);checkDepthLabelling(actualD);
checkM(expectedPTA,actualE,config,converter);checkDepthLabelling(actualE);