TextClassification.Builder

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 functions

TextClassification.Builder

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

TextClassification

Builds and returns a TextClassification object.

TextClassification.Builder!
setEntityType(
    type: String,
    confidenceScore: @FloatRange(from = 0.0, to = 1.0) Float
)

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

TextClassification.Builder
setExtras(extras: Bundle?)

Sets the extended, vendor specific data.

TextClassification.Builder
setId(id: String?)

Sets an id for the TextClassification object.

TextClassification.Builder!

Sets the classified text.

Public constructors

Builder

Builder()

Public functions

addAction

fun addAction(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.

build

fun build(): TextClassification

Builds and returns a TextClassification object.

setEntityType

fun setEntityType(
    type: String,
    confidenceScore: @FloatRange(from = 0.0, to = 1.0) 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: @FloatRange(from = 0.0, to = 1.0) 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.

setExtras

fun setExtras(extras: Bundle?): TextClassification.Builder

Sets the extended, vendor specific data.

setId

fun setId(id: String?): TextClassification.Builder

Sets an id for the TextClassification object.

setText

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

Sets the classified text.