All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.digitalcollections.solrocr.lucene.OcrPassageScorer Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 0.7.0
Show 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;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy