Record Class ExtractionResult<T>
java.lang.Object
java.lang.Record
ai.doctruth.ExtractionResult<T>
- Type Parameters:
T- the extracted value's type (typically a Javarecord).- Record Components:
value- the extracted value.citations- source citations keyed by field path (e.g."partyA","obligations[0].dueDate").confidence- confidence scores keyed by field path.provenance- run-level provenance (model, version, timestamps, retry count).
public record ExtractionResult<T>(T value, Map<String,Citation> citations, Map<String, Confidence> confidence, Provenance provenance)
extends Record
The output of
DocTruth.extract(...).run(): the extracted value plus per-field
citations, per-field confidence scores, and run-level provenance.
Invariants (enforced by the compact constructor):
valueis non-null.citationsandconfidenceare non-null (empty map allowed).provenanceis non-null.
Both maps are defensively copied on construction and exposed as unmodifiable views;
mutating the original input map after construction does not affect the result, and
calling put / remove on the accessor's return value throws
UnsupportedOperationException.
- Since:
- 0.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionExtractionResult(T value, Map<String, Citation> citations, Map<String, Confidence> confidence, Provenance provenance) Creates an instance of aExtractionResultrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecitationsrecord component.Returns the value of theconfidencerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of theprovenancerecord component.Render this result as a W3C PROV-O JSON-LD audit document — the format auditors and compliance teams already know how to ingest.toAuditJson(SignatureProvider signer) Render this result as audit JSON and pipe throughsignerfor tamper-evident persistence.voidtoAuditJson(Path path) WritetoAuditJson()topath, creating parent directories if needed.voidtoAuditJson(Path path, SignatureProvider signer) WritetoAuditJson(SignatureProvider)topath, creating parent directories if needed.final StringtoString()Returns a string representation of this record class.value()Returns the value of thevaluerecord component.
-
Constructor Details
-
ExtractionResult
public ExtractionResult(T value, Map<String, Citation> citations, Map<String, Confidence> confidence, Provenance provenance) Creates an instance of aExtractionResultrecord class.- Parameters:
value- the value for thevaluerecord componentcitations- the value for thecitationsrecord componentconfidence- the value for theconfidencerecord componentprovenance- the value for theprovenancerecord component
-
-
Method Details
-
toAuditJson
Render this result as a W3C PROV-O JSON-LD audit document — the format auditors and compliance teams already know how to ingest. Pretty-printed; UTF-8 safe.- Returns:
- JSON-LD string representation of the extraction's provenance graph.
-
toAuditJson
WritetoAuditJson()topath, creating parent directories if needed.- Throws:
NullPointerException- ifpathis null.IOException- if the file or its parents cannot be written.
-
toAuditJson
Render this result as audit JSON and pipe throughsignerfor tamper-evident persistence. The defaultSignatureProvider.IDENTITYpreserves the existingtoAuditJson()bytes unchanged; custom implementations can wrap or sign the JSON before it leaves the JVM.- Throws:
NullPointerException- ifsigneris null.
-
toAuditJson
WritetoAuditJson(SignatureProvider)topath, creating parent directories if needed.- Throws:
NullPointerException- if either argument is null.IOException- if the file or its parents cannot be written.
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
value
-
citations
-
confidence
Returns the value of theconfidencerecord component.- Returns:
- the value of the
confidencerecord component
-
provenance
Returns the value of theprovenancerecord component.- Returns:
- the value of the
provenancerecord component
-