com.hrstc.lucene
Class Utils
java.lang.Object
com.hrstc.lucene.Utils
public class Utils
- extends java.lang.Object
Field Summary |
static org.apache.lucene.document.Document |
doc
|
static int |
docTermCount
|
static java.util.Hashtable<java.lang.String,java.lang.Float> |
idfTbl
|
static float |
maxIdf
|
static java.util.Vector<org.apache.lucene.search.TermQuery> |
terms
|
Constructor Summary |
Utils()
|
Method Summary |
static float |
coord(java.util.Vector<org.apache.lucene.search.TermQuery> terms,
org.apache.lucene.document.Document doc,
int docId,
org.apache.lucene.search.Similarity similarity,
org.apache.lucene.index.FilterIndexReader idxReader)
|
static float |
getBoostNorm(org.apache.lucene.search.TermQuery termQuery,
java.util.Vector<org.apache.lucene.search.TermQuery> terms)
Returns normalized boost factor |
static int |
getDocTermCount(org.apache.lucene.document.Document doc)
|
static int |
getDocTermCount(org.apache.lucene.document.Document doc,
boolean cache)
|
static float |
getIDF(java.lang.String termStr,
org.apache.lucene.search.Searcher searcher,
org.apache.lucene.search.Similarity similarity)
|
static float |
getIDFNorm(java.lang.String termStr,
java.util.Vector<org.apache.lucene.search.TermQuery> terms,
org.apache.lucene.search.Searcher searcher,
org.apache.lucene.search.Similarity similarity)
|
static float |
getIDFNorm(java.lang.String termStr,
java.util.Vector<org.apache.lucene.search.TermQuery> terms,
org.apache.lucene.search.Searcher searcher,
org.apache.lucene.search.Similarity similarity,
boolean cache)
|
private static float |
getLengthNorm(org.apache.lucene.document.Document doc,
org.apache.lucene.search.Similarity similarity)
Use similarity class instead |
private static float |
getMaxIDF(java.util.Vector<org.apache.lucene.search.TermQuery> terms,
org.apache.lucene.search.Searcher searcher,
org.apache.lucene.search.Similarity similarity)
|
static float |
getTF(java.lang.String term,
int docId,
org.apache.lucene.index.FilterIndexReader idxReader)
|
static float |
getTFNorm(java.lang.String termStr,
org.apache.lucene.document.Document doc,
int docId,
org.apache.lucene.search.Similarity similarity,
org.apache.lucene.index.FilterIndexReader idxReader)
|
static float |
getTFNorm(java.lang.String termStr,
org.apache.lucene.document.Document doc,
int docId,
org.apache.lucene.search.Similarity similarity,
org.apache.lucene.index.FilterIndexReader idxReader,
boolean cache)
|
static float |
scoreTerm(org.apache.lucene.document.Document doc,
java.lang.String termStr,
int docId,
org.apache.lucene.search.Similarity similarity,
org.apache.lucene.index.FilterIndexReader idxReader,
org.apache.lucene.search.Searcher searcher)
score(q,d) =?(t in q) tf(t in d) * idf(t) * getBoost(t.field in d) * lengthNorm(t.field in d) * coord(q,d) * queryNorm(q) |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
maxIdf
public static float maxIdf
idfTbl
public static java.util.Hashtable<java.lang.String,java.lang.Float> idfTbl
terms
public static java.util.Vector<org.apache.lucene.search.TermQuery> terms
doc
public static org.apache.lucene.document.Document doc
docTermCount
public static int docTermCount
Utils
public Utils()
scoreTerm
public static float scoreTerm(org.apache.lucene.document.Document doc,
java.lang.String termStr,
int docId,
org.apache.lucene.search.Similarity similarity,
org.apache.lucene.index.FilterIndexReader idxReader,
org.apache.lucene.search.Searcher searcher)
throws java.io.IOException
- score(q,d) =?(t in q) tf(t in d) * idf(t) * getBoost(t.field in d) * lengthNorm(t.field in d) * coord(q,d) * queryNorm(q)
- Parameters:
term
- similarity
-
- Returns:
-
- Throws:
java.io.IOException
getIDF
public static float getIDF(java.lang.String termStr,
org.apache.lucene.search.Searcher searcher,
org.apache.lucene.search.Similarity similarity)
throws java.io.IOException
- Throws:
java.io.IOException
getIDFNorm
public static float getIDFNorm(java.lang.String termStr,
java.util.Vector<org.apache.lucene.search.TermQuery> terms,
org.apache.lucene.search.Searcher searcher,
org.apache.lucene.search.Similarity similarity)
throws java.io.IOException
- Throws:
java.io.IOException
getIDFNorm
public static float getIDFNorm(java.lang.String termStr,
java.util.Vector<org.apache.lucene.search.TermQuery> terms,
org.apache.lucene.search.Searcher searcher,
org.apache.lucene.search.Similarity similarity,
boolean cache)
throws java.io.IOException
- Parameters:
termStr
- terms
- searcher
- similarity
- cache
- - indicates if values will be cached
- Returns:
-
- Throws:
java.io.IOException
getMaxIDF
private static float getMaxIDF(java.util.Vector<org.apache.lucene.search.TermQuery> terms,
org.apache.lucene.search.Searcher searcher,
org.apache.lucene.search.Similarity similarity)
throws java.io.IOException
- Throws:
java.io.IOException
getLengthNorm
private static float getLengthNorm(org.apache.lucene.document.Document doc,
org.apache.lucene.search.Similarity similarity)
- Use similarity class instead
getTFNorm
public static float getTFNorm(java.lang.String termStr,
org.apache.lucene.document.Document doc,
int docId,
org.apache.lucene.search.Similarity similarity,
org.apache.lucene.index.FilterIndexReader idxReader)
throws java.io.IOException
- Throws:
java.io.IOException
getTFNorm
public static float getTFNorm(java.lang.String termStr,
org.apache.lucene.document.Document doc,
int docId,
org.apache.lucene.search.Similarity similarity,
org.apache.lucene.index.FilterIndexReader idxReader,
boolean cache)
throws java.io.IOException
- Returns:
- tf * lengthNorm = [0;1]
- Throws:
java.io.IOException
getDocTermCount
public static int getDocTermCount(org.apache.lucene.document.Document doc)
getDocTermCount
public static int getDocTermCount(org.apache.lucene.document.Document doc,
boolean cache)
getTF
public static float getTF(java.lang.String term,
int docId,
org.apache.lucene.index.FilterIndexReader idxReader)
throws java.io.IOException
- Throws:
java.io.IOException
coord
public static float coord(java.util.Vector<org.apache.lucene.search.TermQuery> terms,
org.apache.lucene.document.Document doc,
int docId,
org.apache.lucene.search.Similarity similarity,
org.apache.lucene.index.FilterIndexReader idxReader)
throws java.io.IOException
- Throws:
java.io.IOException
getBoostNorm
public static float getBoostNorm(org.apache.lucene.search.TermQuery termQuery,
java.util.Vector<org.apache.lucene.search.TermQuery> terms)
- Returns normalized boost factor
- Parameters:
termQuery
- terms
-
- Returns: