jcolibri.method.retrieve.NNretrieval.similarity.local.textual
Class LuceneTextSimilarity

java.lang.Object
  extended by jcolibri.method.retrieve.NNretrieval.similarity.InContextLocalSimilarityFunction
      extended by jcolibri.method.retrieve.NNretrieval.similarity.local.textual.LuceneTextSimilarity
All Implemented Interfaces:
LocalSimilarityFunction

public class LuceneTextSimilarity
extends InContextLocalSimilarityFunction

Computes the similarity between two texts using Lucene.
It is applicable to any Text object.
Requires the previous execution of the method jcolibri.method.precycle.LuceneIndexCreator to create a LuceneIndex.
Test 13 shows how to use this similarity measure.

Version:
1.0
Author:
Juan A. Recio-Garcia
See Also:
Text, LuceneIndexCreator, Test13b

Field Summary
 
Fields inherited from class jcolibri.method.retrieve.NNretrieval.similarity.InContextLocalSimilarityFunction
_case, _query, attribute, componentOfCase, componentOfQuery
 
Constructor Summary
LuceneTextSimilarity(LuceneIndex index, CBRQuery query, Attribute at, boolean normalized)
          Creates a LuceneTextSimilarity object.
 
Method Summary
 double compute(java.lang.Object caseObject, java.lang.Object queryObject)
          Computes the similarity between two objects
 boolean isApplicable(java.lang.Object o1, java.lang.Object o2)
          Indicates if the function is applicable to two objects
 
Methods inherited from class jcolibri.method.retrieve.NNretrieval.similarity.InContextLocalSimilarityFunction
setContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LuceneTextSimilarity

public LuceneTextSimilarity(LuceneIndex index,
                            CBRQuery query,
                            Attribute at,
                            boolean normalized)
Creates a LuceneTextSimilarity object. This constructor pre-computes the similarity of the query with the textaul attributes of the case (as these attributes are in the index).

Parameters:
index - Index that contains the attributes of the case
query - query that will be compared
at - textual attribute of the case or query object that is being compared
normalized - if the Lucene result must be normalized to [0..1]
Method Detail

compute

public double compute(java.lang.Object caseObject,
                      java.lang.Object queryObject)
               throws NoApplicableSimilarityFunctionException
Description copied from interface: LocalSimilarityFunction
Computes the similarity between two objects

Parameters:
caseObject - object of the case
queryObject - object of the query
Returns:
a value between [0..1]
Throws:
NoApplicableSimilarityFunctionException

isApplicable

public boolean isApplicable(java.lang.Object o1,
                            java.lang.Object o2)
Description copied from interface: LocalSimilarityFunction
Indicates if the function is applicable to two objects


GAIA - Group for Artificial Intelligence Applications
http://gaia.fdi.ucm.es