TextSelection

public final class TextSelection
extends Object

java.lang.Object
   ↳ androidx.textclassifier.TextSelection


Information about where text selection should be.

Summary

Nested classes

class TextSelection.Builder

Builder used to build TextSelection objects. 

class TextSelection.Request

A request object for generating TextSelection. 

Public methods

static TextSelection createFromBundle(Bundle bundle)

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

float getConfidenceScore(String entity)

Returns the confidence score for the specified entity.

String getEntity(int index)

Returns the entity at the specified index.

int getEntityCount()

Returns the number of entities found in the classified text.

Bundle getExtras()

Returns the extended, vendor specific data.

String getId()

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

int getSelectionEndIndex()

Returns the end index of the text selection.

int getSelectionStartIndex()

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 createFromBundle(Bundle).

String toString()

Inherited methods

Public methods

createFromBundle

public static TextSelection createFromBundle (Bundle bundle)

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

Parameters
bundle Bundle

Returns
TextSelection

getConfidenceScore

public 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.

Parameters
entity String

Returns
float

Value is between 0.0 and 1.0 inclusive.

getEntity

public String getEntity (int index)

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

Parameters
index int

Returns
String

Throws
IndexOutOfBoundsException if the specified index is out of range.

getEntityCount

public int getEntityCount ()

Returns the number of entities found in the classified text.

Returns
int

getExtras

public 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.

Returns
Bundle

getId

public String getId ()

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

Returns
String

getSelectionEndIndex

public int getSelectionEndIndex ()

Returns the end index of the text selection.

Returns
int

getSelectionStartIndex

public int getSelectionStartIndex ()

Returns the start index of the text selection.

Returns
int

toBundle

public Bundle toBundle ()

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

Returns
Bundle

toString

public String toString ()

Returns
String