Iterator<List<String>> questionIt = questions.iterator();
while(questionIt.hasNext()){
List<String> question = questionIt.next();
boolean accepted = DeterministicDirectedSparseGraph.isAccept(pair.getQ());
Pair<Integer,String> answer = CheckWithEndUser(new LearnerGraph(model,Configuration.getDefaultConfiguration()),question, AbstractOracle.USER_CANCELLED,null, new Object [] {"Test"});
if (answer.firstElem == AbstractOracle.USER_CANCELLED)
{
System.out.println("CANCELLED");
return null;
}
Vertex tempVertex = getVertex(temp, question);
if(answer.firstElem == AbstractOracle.USER_ACCEPTED){
sPlus.add(question);
if(!DeterministicDirectedSparseGraph.isAccept(tempVertex))
{
restartLearning = true;break;
}
}
else if(answer.firstElem >= 0){
assert answer.firstElem < question.size();
LinkedList<String> subAnswer = new LinkedList<String>();subAnswer.addAll(question.subList(0, answer.firstElem+1));sMinus.add(subAnswer);
// sMinus.add(question.subList(0, answer+1)); // KIRR: without a `proper' collection in the set, I cannot serialise the sets into XML
if((answer.firstElem==question.size()-1)&&!DeterministicDirectedSparseGraph.isAccept(tempVertex)){
continue;
}
assert accepted == true;
restartLearning = true;
break;
}
else if (answer.firstElem == AbstractOracle.USER_ACCEPTED-1){
// sPlus = this.parentFrame.addTest(sPlus);
if(sPlus == null)
return new LearnerGraph(model,Configuration.getDefaultConfiguration());
if(!containsSubString(sPlus, question))
return learnMachine(sPlus, sMinus);
}
}
if (restartLearning)
{// restart learning
model = createAugmentedPTA(sPlus, sMinus);// KIRR: node labelling is done by createAugmentedPTA
DeterministicDirectedSparseGraph.findInitial(model).setUserDatum(JUConstants.COLOUR, JUConstants.RED, UserData.SHARED);
setChanged();
}
else
// keep going with the existing model
model = temp;
possibleMerges = chooseStatePairs(model, sPlus, sMinus);
}
updateGraph(new LearnerGraph(model,Configuration.getDefaultConfiguration()));
return new LearnerGraph(model,Configuration.getDefaultConfiguration());
}