001/**
002 * InContextLocalSimilarityFunction.java
003 * jCOLIBRI2 framework. 
004 * @author Juan A. Recio-Garc�a.
005 * GAIA - Group for Artificial Intelligence Applications
006 * http://gaia.fdi.ucm.es
007 * 26/06/2007
008 */
009package es.ucm.fdi.gaia.jcolibri.method.retrieve.NNretrieval.similarity;
010
011import es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCase;
012import es.ucm.fdi.gaia.jcolibri.cbrcore.CBRQuery;
013import es.ucm.fdi.gaia.jcolibri.cbrcore.CaseComponent;
014
015/**
016 * Extension of the LocalSimilarityFunction for measures that need data about other attributes of the case or current CaseComponent.<br>
017 * Through the inherited class-attributes subclasses can use information about the "context" (other neighbour attributes) of the compared attribute.<br>
018 * The context information is set by the StandardGlobalSimilarityFunction in a transparent way.
019 * <br>
020 * An example is jcolibri.method.retrieve.NNretrieval.similarity.local.textual.LuceneTextSimilarity
021 * @author Juan A. Recio-Garcia
022 * @version 1.0
023 * @see StandardGlobalSimilarityFunction
024 */
025public abstract class InContextLocalSimilarityFunction implements LocalSimilarityFunction
026{
027    /**
028     * component of the case that this attribute belongs to
029     */
030    protected CaseComponent componentOfCase;
031    /**
032     * component of the query that this attribute belongs to
033     */
034    protected CaseComponent componentOfQuery;
035    /**
036     * case that this attribute belongs to
037     */
038    protected CBRCase _case;
039    /**
040     * query that this attribute belongs to
041     */
042    protected CBRQuery _query;
043    /**
044     * name of the attribute
045     */
046    protected String attribute;
047    
048    /**
049     * Method used by the StandardGlobalSimilarityFunction (or any other future implementation of the GlobalSimilarityFunction) 
050     * to set the context of this LocalSimilarityFunction.
051     * @param componentOfCase that this attribute belongs to
052     * @param componentOfQuery that this attribute belongs to
053     * @param _case that this attribute belongs to
054     * @param _query that this attribute belongs to
055     * @param attributeName is the name of the attribute
056     */
057    public void setContext(CaseComponent componentOfCase, CaseComponent componentOfQuery, CBRCase _case, CBRQuery _query, String attributeName) {
058        this.componentOfCase = componentOfCase;
059        this.componentOfQuery = componentOfQuery;
060        this._case = _case;
061        this._query = _query;
062        this.attribute = attributeName;
063    }
064
065}