All Downloads are FREE. Search and download functionalities are using the official Maven repository.

es.ucm.fdi.gaia.jcolibri.method.reuse.CombineQueryAndCasesMethod Maven / Gradle / Ivy

Go to download

jCOLIBRI is a java framework for the development of Case-Based Reasoning systems.

There is a newer version: 3.2
Show newest version
/**
 * CombineQueryAndCasesMethod.java
 * jCOLIBRI2 framework. 
 * @author Juan A. Recio-Garc�a.
 * GAIA - Group for Artificial Intelligence Applications
 * http://gaia.fdi.ucm.es
 * 05/01/2007
 */
package es.ucm.fdi.gaia.jcolibri.method.reuse;


import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.apache.log4j.LogManager;

import es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCase;
import es.ucm.fdi.gaia.jcolibri.cbrcore.CBRQuery;
import es.ucm.fdi.gaia.jcolibri.util.CopyUtils;

/**
 * Method to combine the description of a query with the other components of a case: solution, result and justification of solution.
 * @author Juan A. Recio-Garcia
 * @version 2.0
 */
public class CombineQueryAndCasesMethod {

	/**
	 * Combienes some cases with a query. 
	 * This method creates a new copy for each case and overwrites their description with the description of the query.
	 */
	public static List combine(CBRQuery query, Collection cases)
	{
		ArrayList res = new ArrayList();
		
		for(CBRCase orig: cases)
		{
			try {
				CBRCase copy = orig.getClass().newInstance();
				
				copy.setDescription(CopyUtils.copyCaseComponent(query.getDescription()));
				copy.setSolution(CopyUtils.copyCaseComponent(orig.getSolution()));
				copy.setJustificationOfSolution(CopyUtils.copyCaseComponent(orig.getJustificationOfSolution()));
				copy.setResult(CopyUtils.copyCaseComponent(orig.getResult()));
				
				res.add(copy);
				
				
			} catch (Exception e) {
				LogManager.getLogger(CombineQueryAndCasesMethod.class).error("Error combining cases and query", e);
			} 
		}	
		return res;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy