querqy.lucene.rewrite.prms.PRMSDisjunctionMaxQuery Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of querqy-lucene Show documentation
Show all versions of querqy-lucene Show documentation
Querqy library for query rewriting for Lucene
The newest version!
/**
*
*/
package querqy.lucene.rewrite.prms;
import java.io.IOException;
import java.util.List;
import org.apache.lucene.index.IndexReader;
/**
* @author rene
*
*/
public class PRMSDisjunctionMaxQuery implements PRMSQuery {
final List disjuncts;
private Double probability = null;
public PRMSDisjunctionMaxQuery(List disjuncts) {
if (disjuncts.isEmpty()) {
throw new IllegalArgumentException("disjuncts.size() > 0 expected");
}
this.disjuncts = disjuncts;
}
/* (non-Javadoc)
* @see querqy.lucene.rewrite.prms.PRMSQuery#calculateProbability(org.apache.lucene.index.IndexReader)
*/
@Override
public double calculateLikelihood(IndexReader indexReader)
throws IOException {
if (probability == null) {
double max = 0.0;
for (PRMSQuery clause: disjuncts) {
max = Math.max(max, clause.calculateLikelihood(indexReader));
}
probability = max;
}
return probability;
}
public List getDisjuncts() {
return disjuncts;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy