Record Class TermVector
- Record Components:
term- The term string. Must not benull.frequency- The number of occurrences in the document. Must be at least one.spans- The occurrence spans in original text coordinates, one per occurrence, or an empty list for a scoring-only vector. Must not benullor containnulland, when non-empty, must hold exactlyfrequencyspans.
The term() is the term's identity as the producing annotator determined
it, typically a normalized form; the spans() are the occurrence offsets and
always point into the document's original text, never into a normalized form,
so an index consumer can highlight every occurrence in what the caller supplied.
A term vector comes in one of two shapes, told apart by whether spans() is
empty. A full vector carries one span per occurrence, so
spans().size() == frequency(). A scoring-only vector carries no spans
at all, so consumers that only need term frequencies do not pay for offset storage.
There is no third shape: a non-empty span list must match the frequency exactly.
Instances are immutable: the span list is copied on construction and the copy is unmodifiable.
- Since:
- 3.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionTermVector(String term, int frequency, List<Span> spans) Validates the term vector and detaches the span list from the caller's input. -
Method Summary
Modifier and TypeMethodDescriptionstatic TermVectorCreates a scoring-onlyTermVectorthat carries the occurrence count without any offsets.final booleanIndicates whether some other object is "equal to" this one.intReturns the value of thefrequencyrecord component.final inthashCode()Returns a hash code value for this object.spans()Returns the value of thespansrecord component.term()Returns the value of thetermrecord component.final StringtoString()Returns a string representation of this record class.static TermVectorCreates a fullTermVectorwhose frequency is derived from the occurrence spans.
-
Constructor Details
-
TermVector
Validates the term vector and detaches the span list from the caller's input.- Throws:
IllegalArgumentException- Thrown iftermisnull,frequencyis below one,spansis or containsnull, or a non-emptyspanslist does not hold exactlyfrequencyspans.
-
-
Method Details
-
withSpans
Creates a fullTermVectorwhose frequency is derived from the occurrence spans.- Parameters:
term- The term string. Must not benull.spans- The occurrence spans in original text coordinates. Must not benullor empty.- Returns:
- A
TermVectorwithfrequency() == spans.size(). Nevernull. - Throws:
IllegalArgumentException- Thrown iftermisnullorspansisnullor empty.
-
count
Creates a scoring-onlyTermVectorthat carries the occurrence count without any offsets.- Parameters:
term- The term string. Must not benull.frequency- The number of occurrences in the document. Must be at least one.- Returns:
- A
TermVectorwhosespans()is empty. Nevernull. - Throws:
IllegalArgumentException- Thrown iftermisnullorfrequencyis below one.
-
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. -
term
-
frequency
-
spans
-