Builder

class Builder
kotlin.Any
   ↳ 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

Builder for building TextClassification objects.

Public methods
TextClassification.Builder
setId(@Nullable id: String?)

Sets an id for the TextClassification object.

TextClassification.Builder
addAction(@NonNull action: RemoteActionCompat)

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

TextClassification.Builder!
setEntityType(@NonNull type: String, confidenceScore: Float)

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

TextClassification.Builder
setExtras(@Nullable extras: Bundle?)

Sets the extended, vendor specific data.

TextClassification.Builder!
setText(@Nullable text: CharSequence?)

Sets the classified text.

TextClassification

Builds and returns a TextClassification object.

Public constructors

<init>

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(); 

Public methods

setId

@NonNull fun setId(@Nullable id: String?): TextClassification.Builder

Sets an id for the TextClassification object.

addAction

@NonNull fun addAction(@NonNull action: RemoteActionCompat): TextClassification.Builder

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.

setEntityType

fun setEntityType(@NonNull type: String, confidenceScore: Float): TextClassification.Builder!

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
confidenceScore String: 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.

setExtras

@NonNull fun setExtras(@Nullable extras: Bundle?): TextClassification.Builder

Sets the extended, vendor specific data.

setText

fun setText(@Nullable text: CharSequence?): TextClassification.Builder!

Sets the classified text.

build

@NonNull fun build(): TextClassification

Builds and returns a TextClassification object.