TextSelection
class TextSelection
kotlin.Any | |
↳ | androidx.textclassifier.TextSelection |
Information about where text selection should be.
Summary
Nested classes | |
---|---|
Builder used to build |
|
A request object for generating TextSelection. |
Public methods | |
---|---|
static TextSelection |
createFromBundle(@NonNull bundle: Bundle) Extracts a selection from a bundle that was added using |
Float |
getConfidenceScore(entity: String!) Returns the confidence score for the specified entity. |
String |
getEntityType(index: Int) Returns the entity type at the specified index. |
Int |
Returns the number of entity types found in the classified text. |
Bundle |
Returns the extended, vendor specific data. |
String? |
getId() Returns the id, if one exists, for this object. |
Int |
Returns the end index of the text selection. |
Int |
Returns the start index of the text selection. |
Bundle |
toBundle() Adds this selection to a Bundle that can be read back with the same parameters to |
String |
toString() |
Public methods
createFromBundle
@NonNull static fun createFromBundle(@NonNull bundle: Bundle): TextSelection
Extracts a selection from a bundle that was added using toBundle()
.
getConfidenceScore
@FloatRange(0.0, 1.0) fun getConfidenceScore(entity: String!): Float
Returns the confidence score for the specified entity. The value ranges from 0 (low confidence) to 1 (high confidence). 0 indicates that the entity was not found for the classified text.
getEntityType
@NonNull fun getEntityType(index: Int): String
Returns the entity type at the specified index. Entities are ordered from high confidence to low confidence.
Exceptions | |
---|---|
IndexOutOfBoundsException |
if the specified index is out of range. |
See Also
getEntityTypeCount
@IntRange(0) fun getEntityTypeCount(): Int
Returns the number of entity types found in the classified text.
getExtras
@NonNull fun getExtras(): Bundle
Returns the extended, vendor specific data.
NOTE: Each call to this method returns a new bundle copy so clients should prefer to hold a reference to the returned bundle rather than frequently calling this method. Avoid updating the content of this bundle. On pre-O devices, the values in the Bundle are not deep copied.
getSelectionStartIndex
fun getSelectionStartIndex(): Int
Returns the start index of the text selection.
toBundle
@NonNull fun toBundle(): Bundle
Adds this selection to a Bundle that can be read back with the same parameters to createFromBundle(Bundle)
.
toString
fun toString(): String