Closed PetrToman closed 10 years ago
Here is a solution:
import java.util.Collections;
import java.util.Comparator;
import org.encog.workbench.util.FileUtil;
public List<ProjectTraining> getTrainingData(final String sortFirst) {
List<ProjectTraining> list = getTrainingData();
Collections.sort(list, new Comparator<ProjectTraining>() {
@Override
public int compare(ProjectTraining p1, ProjectTraining p2) {
boolean isFirst1 = FileUtil.getFileName(p1.getFile()).endsWith(sortFirst);
boolean isFirst2 = FileUtil.getFileName(p2.getFile()).endsWith(sortFirst);
if (isFirst1 && !isFirst2) return -1;
if (isFirst2 && !isFirst1) return 1;
return p1.getName().compareTo(p2.getName());
}
});
return list;
}
this.trainingSets = EncogWorkBench.getInstance().getTrainingData("_train");
List<ProjectTraining> list = EncogWorkBench.getInstance().getTrainingData("_eval");
import org.encog.workbench.util.FileUtil;
private void ensureNonEvalUnselection()
{
JComboBox comboValidation = (JComboBox) this.comboValidation.getField();
ProjectTraining selectedItem = (ProjectTraining) comboValidation.getSelectedItem();
if (selectedItem == null || !FileUtil.getFileName(selectedItem.getFile()).endsWith("_eval"))
{
comboValidation.setSelectedIndex(-1);
}
}
((JComboBox)this.comboValidation.getField()).setSelectedIndex(-1);
to:
ensureNonEvalUnselection();
Good suggestion, added the suggested code.
If
*_eval.egb
file is present, it is preselected in the training dialog. It would be more useful to preselect a training file (using*_train.egb
mask).