public final class TextSelection


Information about where text selection should be.

Summary

Nested types

public final class TextSelection.Builder

This class is deprecated.

Use android.view.textclassifier.TextSelection.Builder instead.

public final class TextSelection.Request

A request object for generating TextSelection.

A builder for building TextSelection requests.

Public methods

static @NonNull TextSelection

Extracts a selection from a bundle that was added using toBundle.

@FloatRange(from = 0.0, to = 1.0) float

Returns the confidence score for the specified entity.

@NonNull String
getEntityType(int index)

Returns the entity type at the specified index.

@IntRange(from = 0) int

Returns the number of entity types found in the classified text.

@NonNull Bundle

Returns the extended, vendor specific data.

@Nullable String

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.

@NonNull Bundle

Adds this selection to a Bundle that can be read back with the same parameters to createFromBundle.

String

Public methods

createFromBundle

public static @NonNull TextSelection createFromBundle(@NonNull Bundle bundle)

Extracts a selection from a bundle that was added using toBundle.

getConfidenceScore

public @FloatRange(from = 0.0, to = 1.0) float getConfidenceScore(String entity)

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

public @NonNull String getEntityType(int index)

Returns the entity type at the specified index. Entities are ordered from high confidence to low confidence.

Throws
java.lang.IndexOutOfBoundsException

if the specified index is out of range.

See also
getEntityTypeCount

for the number of entities available.

getEntityTypeCount

public @IntRange(from = 0) int getEntityTypeCount()

Returns the number of entity types found in the classified text.

getExtras

public @NonNull Bundle getExtras()

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.

getId

public @Nullable String getId()

Returns the id, if one exists, for this object.

getSelectionEndIndex

public int getSelectionEndIndex()

Returns the end index of the text selection.

getSelectionStartIndex

public int getSelectionStartIndex()

Returns the start index of the text selection.

toBundle

public @NonNull Bundle toBundle()

Adds this selection to a Bundle that can be read back with the same parameters to createFromBundle.

toString

public String toString()