jcolibri.method.retrieve.NNretrieval.similarity.local.textual
Class LuceneTextSimilarity
java.lang.Object
jcolibri.method.retrieve.NNretrieval.similarity.InContextLocalSimilarityFunction
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
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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 casequery
- query that will be comparedat
- textual attribute of the case or query object that is being comparednormalized
- if the Lucene result must be normalized to [0..1]
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 casequeryObject
- 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