Record Class SubwordPiece
- Record Components:
piece- The piece in the vocabulary's normalized form; must not benullor empty.id- The non-negative vocabulary id of the piece.start- The inclusive start offset in the original text.end- The exclusive end offset in the original text; at leaststart.
SubwordTokenizer, including the model representation
and source range.
The piece string is in the tokenizer's normalized form and need not equal the input.
start and end are UTF-16 offsets into the original text, so the
surface associated with this piece is text.subSequence(start, end). A span can include
adjacent source characters when normalization reorders characters. Pieces without source text,
such as control symbols, report an empty span with start == end.
The piece, id and span triple follows the representation established by SentencePiece
(Kudo and Richardson, 2018), whose SentencePieceText.SentencePiece message carries
piece, id and a [begin, end) range into the input, and gives control
symbols an empty surface with begin == end. The surface field of that message
has no counterpart here because it is text.subSequence(start, end). The offsets are
UTF-16 indices rather than the UTF-8 byte offsets used there.
- Since:
- 3.0.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSubwordPiece(String piece, int id, int start, int end) Instantiates aSubwordPiece. -
Method Summary
Modifier and TypeMethodDescriptionintend()Returns the value of theendrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intid()Returns the value of theidrecord component.piece()Returns the value of thepiecerecord component.intstart()Returns the value of thestartrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
SubwordPiece
Instantiates aSubwordPiece.- Throws:
IllegalArgumentException- Thrown ifpieceisnullor empty,idis negative, or the span is negative or inverted.
-
-
Method Details
-
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. -
piece
-
id
-
start
-
end
-