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     */
009    package jcolibri.method.retrieve.NNretrieval.similarity;
010    
011    import jcolibri.cbrcore.CBRCase;
012    import jcolibri.cbrcore.CBRQuery;
013    import 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 jcolibri.method.retrieve.NNretrieval.similarity.StandardGlobalSimilarityFunction
024     * @see jcolibri.method.retrieve.NNretrieval.similarity.local.textual.LuceneTextSimilarity
025     */
026    public abstract class InContextLocalSimilarityFunction implements LocalSimilarityFunction
027    {
028        /**
029         * component of the case that this attribute belongs to
030         */
031        protected CaseComponent componentOfCase;
032        /**
033         * component of the query that this attribute belongs to
034         */
035        protected CaseComponent componentOfQuery;
036        /**
037         * case that this attribute belongs to
038         */
039        protected CBRCase _case;
040        /**
041         * query that this attribute belongs to
042         */
043        protected CBRQuery _query;
044        /**
045         * name of the attribute
046         */
047        protected String attribute;
048        
049        /**
050         * Method used by the StandardGlobalSimilarityFunction (or any other future implementation of the GlobalSimilarityFunction) 
051         * to set the context of this LocalSimilarityFunction.
052         * @param componentOfCase that this attribute belongs to
053         * @param componentOfQuery that this attribute belongs to
054         * @param _case that this attribute belongs to
055         * @param _query that this attribute belongs to
056         * @param attributeName is the name of the attribute
057         */
058        public void setContext(CaseComponent componentOfCase, CaseComponent componentOfQuery, CBRCase _case, CBRQuery _query, String attributeName)
059        {
060            this.componentOfCase = componentOfCase;
061            this.componentOfQuery = componentOfQuery;
062            this._case = _case;
063            this._query = _query;
064            this.attribute = attributeName;
065        }
066    
067    }