de.digitalcollections.solrocr.lucene.OcrPassageScorer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of solr-ocrhighlighting Show documentation
Show all versions of solr-ocrhighlighting Show documentation
Solr plugin to add support for highlighting directly from various OCR formats (hOCR/ALTO/MiniOCR)
without having to store the OCR documents in the index.
The newest version!
package de.digitalcollections.solrocr.lucene;
import org.apache.lucene.search.uhighlight.PassageScorer;
public class OcrPassageScorer extends PassageScorer {
private final boolean boostEarly;
public OcrPassageScorer(float k1, float b, float pivot, boolean boostEarly) {
super(k1, b, pivot);
this.boostEarly = boostEarly;
}
/**
* If enabled with `hl.score.boostEarly`, normalize the passage start so that earlier starts are
* given more weight.
*/
@Override
public float norm(int passageStart) {
if (boostEarly) {
return super.norm(passageStart);
} else {
return passageStart;
}
}
}