Record Class OcrPageResult
java.lang.Object
java.lang.Record
ai.doctruth.spi.OcrPageResult
- Record Components:
text- the full recovered text for the page, in reading order.confidence- average confidence over the page in[0.0, 1.0].regions- optional per-region bounding boxes; richer engines emit one per word / line. Empty list is acceptable for simple engines that only emit page-level text.pageNumber- 1-indexed page number this result corresponds to.
public record OcrPageResult(String text, double confidence, List<OcrRegion> regions, int pageNumber)
extends Record
Output of one
ocr call.
Carries the recovered text plus per-region bounding boxes — these enable
Citation objects to reference a precise pixel rectangle on
the source PDF page, not just a line range. That is the audit-depth differentiator over
libraries that only OCR to a flat text blob.
Invariants (compact constructor):
textnon-null (empty string allowed — flag for genuinely blank pages).confidencein[0.0, 1.0]— typically OCR engine's averaged per-character or per-word confidence. NaN / infinities rejected.regionsnon-null and defensively copied; empty list is allowed.pageNumber >= 1.
- Since:
- 0.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionOcrPageResult(String text, double confidence, List<OcrRegion> regions, int pageNumber) Creates an instance of aOcrPageResultrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the value of theconfidencerecord component.static OcrPageResultempty(int pageNumber) Empty result for blank or non-OCR-able pages.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the value of thepageNumberrecord component.regions()Returns the value of theregionsrecord component.text()Returns the value of thetextrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
OcrPageResult
Creates an instance of aOcrPageResultrecord class.- Parameters:
text- the value for thetextrecord componentconfidence- the value for theconfidencerecord componentregions- the value for theregionsrecord componentpageNumber- the value for thepageNumberrecord component
-
-
Method Details
-
empty
Empty result for blank or non-OCR-able pages. Uses confidence 0.0. -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
text
-
confidence
public double confidence()Returns the value of theconfidencerecord component.- Returns:
- the value of the
confidencerecord component
-
regions
-
pageNumber
public int pageNumber()Returns the value of thepageNumberrecord component.- Returns:
- the value of the
pageNumberrecord component
-