if (e.isStructureOnly()) {  TrainingSetEvent tse = new TrainingSetEvent(this, e.getDataSet()); TestSetEvent tsee = new TestSetEvent(this, e.getDataSet()); notifyTrainingSetProduced(tse); notifyTestSetProduced(tsee); return; }
  public void acceptDataSet(DataSetEvent e) {    if (m_foldThread == null) {      final Instances dataSet = new Instances(e.getDataSet());      m_foldThread = new Thread() {	  public void run() {	    try {	      Random random = new Random(getSeed());	      dataSet.randomize(random);	      if (dataSet.classIndex() >= 0 && 		  dataSet.attribute(dataSet.classIndex()).isNominal()) {		dataSet.stratify(getFolds());		if (m_logger != null) {		  m_logger.logMessage("CrossValidationFoldMaker : "				      +"stratifying data");		}	      }	      	      for (int i = 0; i < getFolds(); i++) {		if (m_foldThread == null) {		  if (m_logger != null) {		    m_logger.logMessage("Cross validation has been canceled!");		    m_logger.statusMessage("OK");		  }		  // exit gracefully		  break;		}		Instances train = dataSet.trainCV(getFolds(), i, random);		Instances test  = dataSet.testCV(getFolds(), i);				// inform all training set listeners		TrainingSetEvent tse = new TrainingSetEvent(this, train);		tse.m_setNumber = i+1; tse.m_maxSetNumber = getFolds();		if (m_foldThread != null) {		  //		  System.err.println("--Just before notify training set");		  notifyTrainingSetProduced(tse);		  //		  System.err.println("---Just after notify");		}	      		// inform all test set listeners		TestSetEvent teste = new TestSetEvent(this, test);		teste.m_setNumber = i+1; teste.m_maxSetNumber = getFolds();		if (m_foldThread != null) {		  notifyTestSetProduced(teste);		}	      }	    } catch (Exception ex) {	      ex.printStackTrace();	    } finally {	      if (isInterrupted()) {		System.err.println("Cross validation interrupted");	      }	      block(false);	    }	  }	};      m_foldThread.setPriority(Thread.MIN_PRIORITY);      m_foldThread.start();      //      if (m_foldThread.isAlive()) {      block(true);	//      }      m_foldThread = null;    }  }