public final class

TextClassification.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.textclassifier.TextClassification.Builder

Overview

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

Constructors
publicBuilder()

Methods
public TextClassification.BuilderaddAction(RemoteActionCompat action)

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

public TextClassificationbuild()

Builds and returns a TextClassification object.

public TextClassification.BuildersetEntityType(java.lang.String type, float confidenceScore)

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

public TextClassification.BuildersetExtras(Bundle extras)

Sets the extended, vendor specific data.

public TextClassification.BuildersetId(java.lang.String id)

Sets an id for the TextClassification object.

public TextClassification.BuildersetText(java.lang.CharSequence text)

Sets the classified text.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Methods

public TextClassification.Builder setText(java.lang.CharSequence text)

Sets the classified text.

public TextClassification.Builder setEntityType(java.lang.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:

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.

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.

public TextClassification.Builder setId(java.lang.String id)

Sets an id for the TextClassification object.

public TextClassification.Builder setExtras(Bundle extras)

Sets the extended, vendor specific data.

public TextClassification build()

Builds and returns a TextClassification object.