/*
* Case Based Student Performance Determination System:
* Designed by Degefe Ayele under the active guidance and follow up of:
* 1: Dr.Million Meshesha (PHD)
* 2: Mr Tilahun Shiferaw(Assistant Professor)
*/
package cbr;
import jcolibri.cbraplications.StandardCBRApplication;
import jcolibri.cbrcore.CBRCase;
import jcolibri.cbrcore.CBRCaseBase;
import jcolibri.cbrcore.CBRQuery;
import jcolibri.cbrcore.Connector;
import jcolibri.exception.ExecutionException;
import jcolibri.exception.InitializingException;
import jcolibri.method.retrieve.FilterBasedRetrieval.FilterConfig;
import jcolibri.method.retrieve.NNretrieval.NNConfig;
import jcolibri.connector.PlainTextConnector;
import jcolibri.method.retrieve.NNretrieval.similarity.global.Average;
import jcolibri.method.retrieve.NNretrieval.similarity.local.Interval;
import jcolibri.method.retrieve.NNretrieval.similarity.local.Equal;
import jcolibri.method.retrieve.NNretrieval.similarity.local.MaxString;
import jcolibri.method.retrieve.NNretrieval.NNScoringMethod;
import jcolibri.method.retrieve.selection.SelectCases;
import jcolibri.method.retrieve.RetrievalResult;
import jcolibri.casebase.LinearCaseBase;
import jcolibri.method.retrieve.FilterBasedRetrieval.FilterBasedRetrievalMethod;
//import jcolibri.method.retrieve.FilterBasedRetrieval.FilterConfig;
import java.util.Iterator;
import java.util.Collection;
import javax.annotation.Generated;
import representation.CaseDescription;
//import representation.CaseSolution;
//import jcolibri.method.retrieve.NNretrieval.NNConfig;
import jcolibri.cbrcore.Attribute;
public class CBRApplication implements StandardCBRApplication {
private static CBRApplication _instance = null;
public static CBRApplication getInstance() {
if (_instance == null) {
_instance = new CBRApplication();
}
return _instance;
}
CBRCaseBase _caseBase;
Connector _connector;
NNConfig simConfig;
FilterConfig filterConfig;
Collection<Attribute> hiddenAtts;
ResultDisplay resultDialog;
//******************************************************************/
// Configuration
//******************************************************************/
public void configure() throws ExecutionException {
try {
_connector = new PlainTextConnector();
_connector.initFromXMLfile(jcolibri.util.FileIO.findFile("C:\\workspace11\\CBRProject\\config\\plainTextConnectorConfig.xml"));
_caseBase = new LinearCaseBase();
simConfig = new NNConfig();
simConfig.setDescriptionSimFunction(new Average());
simConfig.addMapping(
new Attribute("CaseId", CaseDescription.class),
new Interval(1));
simConfig.addMapping(new Attribute("Age", CaseDescription.class), new Interval(1));
simConfig.addMapping(new Attribute("Gender", CaseDescription.class), new MaxString());
simConfig.addMapping(new Attribute("Program_Type",CaseDescription.class), new MaxString());
simConfig.addMapping(new Attribute("Field_of_Study",CaseDescription.class), new MaxString());
simConfig.addMapping(new Attribute("First_Year_First_Semester_Course_Load", CaseDescription.class), new Interval(1));
simConfig.addMapping(new Attribute("First_Year_First_Semester_GPA",CaseDescription.class), new Equal());
simConfig.addMapping(new Attribute("First_Year_First_Semester_Status", CaseDescription.class), new MaxString());
simConfig.addMapping(new Attribute("First_Year_Second_Semester_Course_Load", CaseDescription.class), new Interval(1));
simConfig.addMapping(new Attribute("First_Year_Second_Semester_GPA",CaseDescription.class), new Equal());
simConfig.addMapping(new Attribute("First_Year_Second_Semester_Status", CaseDescription.class), new MaxString());
simConfig.addMapping(new Attribute("Second_Year_First_Semester_Course_Load", CaseDescription.class), new Interval(1));
simConfig.addMapping(new Attribute("Second_Year_First_Semester_GPA",CaseDescription.class), new Equal());
simConfig.addMapping(new Attribute( "Second_Year_First_Semester_Status", CaseDescription.class), new MaxString());
simConfig.addMapping(new Attribute("Second_Year_Second_Semester_Course_Load",CaseDescription.class), new Interval(1));
simConfig.addMapping(new Attribute("Second_Year_Second_Semester_GPA", CaseDescription.class), new Equal());
simConfig.addMapping(new Attribute("Second_Year_Second_Semester_Status", CaseDescription.class), new MaxString());
simConfig.addMapping(new Attribute("Third_Year_First_Semester_Course_Load", CaseDescription.class), new Interval(1));
simConfig.addMapping(new Attribute("Third_Year_First_Semester_GPA",CaseDescription.class), new Equal());
simConfig.addMapping(new Attribute("Third_Year_First_Semester_Status", CaseDescription.class), new MaxString());
simConfig.addMapping(new Attribute("Third_Year_Second_Semester_Course_Load", CaseDescription.class), new Interval(1));
simConfig.addMapping(new Attribute("Third_Year_Second_Semester_GPA",CaseDescription.class), new Equal());
simConfig.addMapping(new Attribute("Third_Year_Second_Semester_Status", CaseDescription.class), new MaxString());
configureConnector();
configureCaseBase();
} catch (Exception e) {
throw new ExecutionException(e);
}
}
//******************************************************************/
// Configures the connector
//******************************************************************/
private void configureConnector() throws InitializingException {
}
//******************************************************************/
// Configures the case base
//******************************************************************/
private void configureCaseBase() throws InitializingException {
_caseBase = new jcolibri.casebase.LinearCaseBase();
}
public CBRCaseBase preCycle() throws ExecutionException {
_caseBase.init(_connector);
//******************************************************************/
// Print the cases
//******************************************************************/
java.util.Collection<CBRCase> cases = _caseBase.getCases();
for (Iterator<CBRCase> it = cases.iterator(); it.hasNext();) {
jcolibri.cbrcore.CBRCase c = it.next();
System.out.println(c);
}
return _caseBase;
}
public void cycle(CBRQuery query) throws ExecutionException {
//******************************************************************/
// Execute Filter
//******************************************************************/
Collection<CBRCase> filtered = FilterBasedRetrievalMethod.filterCases( _caseBase.getCases(), query,
filterConfig);
//******************************************************************/
// Execute NN
//******************************************************************/
Collection<RetrievalResult> eval = NNScoringMethod.evaluateSimilarity( filtered, query, simConfig);
//******************************************************************/
// Select cases
//******************************************************************/
Collection<CBRCase> selectedCases = SelectCases.selectTopK(eval, 5);
System.out.println("The selected Cases are...");
for (Iterator<CBRCase> it = selectedCases.iterator(); it.hasNext();)
{
jcolibri.cbrcore.CBRCase c = it.next();
System.out.println(c);
}
}
public void postCycle() throws ExecutionException {
_connector.close();
}
//Main method
public static void main(String[] args) {
CBRApplication cbrApp = new CBRApplication();
// cbrApp.UserSeectionGUL;
try {
cbrApp.configure();
cbrApp.preCycle();
CBRQuery query = new CBRQuery();
CaseDescription cd = new CaseDescription();
// CaseDescription cd = new CaseDescription();
// cd.setCaseId(1);
cd.setAge(22);
cd.setGender("Female");
cd.setProgram_Type("Regular");
cd.setField_of_Study("English Language and Literature");
cd.setFirst_Year_First_Semester_Course_Load(30);
cd.setFirst_Year_First_Semester_GPA(3.04);
cd.setFirst_Year_First_Semester_Status("Good Standing");
cd.setFirst_Year_Second_Semester_Course_Load(30);
cd.setFirst_Year_Second_Semester_GPA(2.71);
cd.setFirst_Year_Second_Semester_Status("Good Standing");
cd.setSecond_Year_First_Semester_Course_Load(30);
cd.setSecond_Year_First_Semester_GPA(2.75);
cd.setSecond_Year_First_Semester_Status("Good Standing");
cd.setSecond_Year_Second_Semester_Course_Load(30);
cd.setSecond_Year_Second_Semester_GPA(2.96);
cd.setSecond_Year_Second_Semester_Status("Good Standing");
cd.setThird_Year_First_Semester_Course_Load(32);
cd.setThird_Year_First_Semester_GPA(3.21);
cd.setThird_Year_First_Semester_Status("Good Standing");
cd.setThird_Year_Second_Semester_Course_Load(29);
cd.setThird_Year_Second_Semester_GPA(3.30);
cd.setThird_Year_Second_Semester_Status("Distinction");
query.setDescription(cd);
cbrApp.cycle(query);
cbrApp.postCycle();
} catch (ExecutionException e) {
System.out.println(e.getMessage());
}
}
}
在尝试使用CBRApplication.java时: ResultDisplay resultDialog;我的代码中的这一行还说ResultDisplay无法解析为一种类型:那么我试图用此代码运行Colibri Studio Eclipse Platform的代码中出现了什么问题? 如何为我的项目导入ResultDisplay包? 如果有人帮助我,我非常感谢。