Package opennlp.spellcheck
Record Class SuggestItem
java.lang.Object
java.lang.Record
opennlp.spellcheck.SuggestItem
- Record Components:
term- the suggested (corrected) term; nevernulleditDistance- the edit distance between the suggestion and the queried termfrequency- the corpus frequency (count) of the suggested term
- All Implemented Interfaces:
Comparable<SuggestItem>
public record SuggestItem(String term, int editDistance, long frequency)
extends Record
implements Comparable<SuggestItem>
An immutable spelling suggestion produced by a
SpellChecker.
The natural ordering sorts by ascending
editDistance() first, then by descending frequency(), and finally by
the term() as a tie-breaker, so the best candidate sorts first. The term
tie-breaker keeps the natural ordering consistent with equals(Object):
two items compare equal only when they are equal, so distinct suggestions that tie on
distance and frequency are never silently dropped from a TreeSet or
TreeMap.
-
Constructor Summary
ConstructorsConstructorDescriptionSuggestItem(String term, int editDistance, long frequency) Creates an instance of aSuggestItemrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(SuggestItem other) intReturns the value of theeditDistancerecord component.final booleanIndicates whether some other object is "equal to" this one.longReturns the value of thefrequencyrecord component.final inthashCode()Returns a hash code value for this object.term()Returns the value of thetermrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
SuggestItem
Creates an instance of aSuggestItemrecord class.- Parameters:
term- the value for thetermrecord componenteditDistance- the value for theeditDistancerecord componentfrequency- the value for thefrequencyrecord component
-
-
Method Details
-
compareTo
- Specified by:
compareToin interfaceComparable<SuggestItem>
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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 '=='. -
term
Returns the value of thetermrecord component.- Returns:
- the value of the
termrecord component
-
editDistance
public int editDistance()Returns the value of theeditDistancerecord component.- Returns:
- the value of the
editDistancerecord component
-
frequency
public long frequency()Returns the value of thefrequencyrecord component.- Returns:
- the value of the
frequencyrecord component
-