The Android Developer Challenge is back! Submit your idea before December 2.

TextClassification.Builder

public static final class TextClassification.Builder
extends Object

java.lang.Object
   ↳ androidx.textclassifier.TextClassification.Builder


Builder for building TextClassification objects.

e.g.

TextClassification classification = new TextClassification.Builder()
          .setText(classifiedText)
          .setEntityType(TextClassifier.TYPE_EMAIL, 0.9)
          .setEntityType(TextClassifier.TYPE_OTHER, 0.1)
          .addAction(remoteAction1)
          .addAction(remoteAction2)
          .build();
 

Summary

Public constructors

TextClassification.Builder()

Public methods

TextClassification.Builder addAction(RemoteActionCompat action)

Adds an action that may be performed on the classified text.

TextClassification build()

Builds and returns a TextClassification object.

TextClassification.Builder setEntityType(String type, float confidenceScore)

Sets an entity type for the classification result and assigns a confidence score.

TextClassification.Builder setExtras(Bundle extras)

Sets the extended, vendor specific data.

TextClassification.Builder setId(String id)

Sets an id for the TextClassification object.

TextClassification.Builder setText(CharSequence text)

Sets the classified text.

Inherited methods

Public constructors

TextClassification.Builder

public TextClassification.Builder ()

Public methods

addAction

public TextClassification.Builder addAction (RemoteActionCompat action)

Adds an action that may be performed on the classified text. Actions should be added in order of likelihood that the user will use them, with the most likely action being added first.

Parameters
action RemoteActionCompat

Returns
TextClassification.Builder

build

public TextClassification build ()

Builds and returns a TextClassification object.

Returns
TextClassification

setEntityType

public TextClassification.Builder setEntityType (String type, 
                float confidenceScore)

Sets an entity type for the classification result and assigns a confidence score. If a confidence score had already been set for the specified entity type, this will override that score.

Parameters
type String

confidenceScore float: a value from 0 (low confidence) to 1 (high confidence). 0 implies the entity does not exist for the classified text. Values greater than 1 are clamped to 1.

Value is between 0.0 and 1.0 inclusive.

Returns
TextClassification.Builder

setExtras

public TextClassification.Builder setExtras (Bundle extras)

Sets the extended, vendor specific data.

Parameters
extras Bundle

Returns
TextClassification.Builder

setId

public TextClassification.Builder setId (String id)

Sets an id for the TextClassification object.

Parameters
id String

Returns
TextClassification.Builder

setText

public TextClassification.Builder setText (CharSequence text)

Sets the classified text.

Parameters
text CharSequence

Returns
TextClassification.Builder