TextClassification.Request.Builder


public final class TextClassification.Request.Builder


A builder for building TextClassification requests.

Summary

Public constructors

Builder(
    @NonNull CharSequence text,
    @IntRange(from = 0) int startIndex,
    @IntRange(from = 0) int endIndex
)

Public constructors

Builder

public Builder(
    @NonNull CharSequence text,
    @IntRange(from = 0) int startIndex,
    @IntRange(from = 0) int endIndex
)
Parameters
@NonNull CharSequence text

text providing context for the text to classify (which is specified by the sub sequence starting at startIndex and ending at endIndex)

@IntRange(from = 0) int startIndex

start index of the text to classify

@IntRange(from = 0) int endIndex

end index of the text to classify

Public methods

build

public @NonNull TextClassification.Request build()

Builds and returns the request object.

setDefaultLocales

public @NonNull TextClassification.Request.Builder setDefaultLocales(@Nullable LocaleListCompat defaultLocales)
Parameters
@Nullable LocaleListCompat defaultLocales

ordered list of locale preferences that may be used to disambiguate the provided text. If no locale preferences exist, set this to null or an empty locale list.

setExtras

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

Sets the extended, vendor specific data.

setReferenceTime

public @NonNull TextClassification.Request.Builder setReferenceTime(@Nullable Long referenceTime)
Parameters
@Nullable Long referenceTime

reference time based on which relative dates (e.g. "tomorrow") should be interpreted. This should usually be the time when the text was originally composed and should be milliseconds from the epoch of 1970-01-01T00:00:00Z(UTC timezone). For example, if there is a message saying "see you 10 days later", and the message was composed yesterday, text classifier will then realize it is indeed means 9 days later from now and classify the text accordingly. If no reference time is set, now is used.