TextClassification.Builder

public final class 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

Public methods

@NonNull TextClassification.Builder

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

@NonNull TextClassification

Builds and returns a TextClassification object.

TextClassification.Builder
setEntityType(
    @NonNull String type,
    @FloatRange(from = 0.0, to = 1.0) float confidenceScore
)

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

@NonNull TextClassification.Builder

Sets the extended, vendor specific data.

@NonNull TextClassification.Builder

Sets an id for the TextClassification object.

TextClassification.Builder

Sets the classified text.

Public constructors

Builder

public Builder()

Public methods

addAction

public @NonNull TextClassification.Builder addAction(@NonNull 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.

build

public @NonNull TextClassification build()

Builds and returns a TextClassification object.

setEntityType

public TextClassification.Builder setEntityType(
    @NonNull String type,
    @FloatRange(from = 0.0, to = 1.0) 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
@FloatRange(from = 0.0, to = 1.0) float confidenceScore

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

public @NonNull TextClassification.Builder setExtras(@Nullable Bundle extras)

Sets the extended, vendor specific data.

setId

public @NonNull TextClassification.Builder setId(@Nullable String id)

Sets an id for the TextClassification object.

setText

public TextClassification.Builder setText(@Nullable CharSequence text)

Sets the classified text.