<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/text/blob/v2.21.1/tensorflow_text/__init__.py) |

Various tensorflow ops related to text-processing.

## Modules

[`metrics`](https://www.tensorflow.org/text/api_docs/python/text/metrics) module: Tensorflow text-processing metrics.

[`tflite_registrar`](https://www.tensorflow.org/text/api_docs/python/text/tflite_registrar) module: tflite_registrar A module with a Python wrapper for TFLite TFText ops.

## Classes

[`class BertTokenizer`](https://www.tensorflow.org/text/api_docs/python/text/BertTokenizer): Tokenizer used for BERT.

[`class ByteSplitter`](https://www.tensorflow.org/text/api_docs/python/text/ByteSplitter): Splits a string tensor into bytes.

[`class Detokenizer`](https://www.tensorflow.org/text/api_docs/python/text/Detokenizer): Base class for detokenizer implementations.

[`class FastBertNormalizer`](https://www.tensorflow.org/text/api_docs/python/text/FastBertNormalizer): Normalizes a tensor of UTF-8 strings.

[`class FastBertTokenizer`](https://www.tensorflow.org/text/api_docs/python/text/FastBertTokenizer): Tokenizer used for BERT, a faster version with TFLite support.

[`class FastSentencepieceTokenizer`](https://www.tensorflow.org/text/api_docs/python/text/FastSentencepieceTokenizer): Sentencepiece tokenizer with tf.text interface.

[`class FastWordpieceTokenizer`](https://www.tensorflow.org/text/api_docs/python/text/FastWordpieceTokenizer): Tokenizes a tensor of UTF-8 string tokens into subword pieces.

[`class FirstNItemSelector`](https://www.tensorflow.org/text/api_docs/python/text/FirstNItemSelector): An `ItemSelector` that selects the first `n` items in the batch.

[`class HubModuleSplitter`](https://www.tensorflow.org/text/api_docs/python/text/HubModuleSplitter): Splitter that uses a Hub module.

[`class HubModuleTokenizer`](https://www.tensorflow.org/text/api_docs/python/text/HubModuleTokenizer): Tokenizer that uses a Hub module.

[`class LastNItemSelector`](https://www.tensorflow.org/text/api_docs/python/text/LastNItemSelector): An `ItemSelector` that selects the last `n` items in the batch.

[`class MaskValuesChooser`](https://www.tensorflow.org/text/api_docs/python/text/MaskValuesChooser): Assigns values to the items chosen for masking.

[`class PhraseTokenizer`](https://www.tensorflow.org/text/api_docs/python/text/PhraseTokenizer): Tokenizes a tensor of UTF-8 string tokens into phrases.

[`class RandomItemSelector`](https://www.tensorflow.org/text/api_docs/python/text/RandomItemSelector): An `ItemSelector` implementation that randomly selects items in a batch.

[`class Reduction`](https://www.tensorflow.org/text/api_docs/python/text/Reduction): Type of reduction to be done by the n-gram op.

[`class RegexSplitter`](https://www.tensorflow.org/text/api_docs/python/text/RegexSplitter): `RegexSplitter` splits text on the given regular expression.

[`class RoundRobinTrimmer`](https://www.tensorflow.org/text/api_docs/python/text/RoundRobinTrimmer): A `Trimmer` that allocates a length budget to segments via round robin.

[`class SentencepieceTokenizer`](https://www.tensorflow.org/text/api_docs/python/text/SentencepieceTokenizer): Tokenizes a tensor of UTF-8 strings.

[`class ShrinkLongestTrimmer`](https://www.tensorflow.org/text/api_docs/python/text/ShrinkLongestTrimmer): A `Trimmer` that truncates the longest segment.

[`class SplitMergeFromLogitsTokenizer`](https://www.tensorflow.org/text/api_docs/python/text/SplitMergeFromLogitsTokenizer): Tokenizes a tensor of UTF-8 string into words according to logits.

[`class SplitMergeTokenizer`](https://www.tensorflow.org/text/api_docs/python/text/SplitMergeTokenizer): Tokenizes a tensor of UTF-8 string into words according to labels.

[`class Splitter`](https://www.tensorflow.org/text/api_docs/python/text/Splitter): An abstract base class for splitting text.

[`class SplitterWithOffsets`](https://www.tensorflow.org/text/api_docs/python/text/SplitterWithOffsets): An abstract base class for splitters that return offsets.

[`class StateBasedSentenceBreaker`](https://www.tensorflow.org/text/api_docs/python/text/StateBasedSentenceBreaker): A `Splitter` that uses a state machine to determine sentence breaks.

[`class Tokenizer`](https://www.tensorflow.org/text/api_docs/python/text/Tokenizer): Base class for tokenizer implementations.

[`class TokenizerWithOffsets`](https://www.tensorflow.org/text/api_docs/python/text/TokenizerWithOffsets): Base class for tokenizer implementations that return offsets.

[`class Trimmer`](https://www.tensorflow.org/text/api_docs/python/text/Trimmer): Truncates a list of segments using a pre-determined truncation strategy.

[`class UnicodeCharTokenizer`](https://www.tensorflow.org/text/api_docs/python/text/UnicodeCharTokenizer): Tokenizes a tensor of UTF-8 strings on Unicode character boundaries.

[`class UnicodeScriptTokenizer`](https://www.tensorflow.org/text/api_docs/python/text/UnicodeScriptTokenizer): Tokenizes UTF-8 by splitting when there is a change in Unicode script.

[`class WaterfallTrimmer`](https://www.tensorflow.org/text/api_docs/python/text/WaterfallTrimmer): A `Trimmer` that allocates a length budget to segments in order.

[`class WhitespaceTokenizer`](https://www.tensorflow.org/text/api_docs/python/text/WhitespaceTokenizer): Tokenizes a tensor of UTF-8 strings on whitespaces.

[`class WordShape`](https://www.tensorflow.org/text/api_docs/python/text/WordShape): Values for the 'pattern' arg of the wordshape op.

[`class WordpieceTokenizer`](https://www.tensorflow.org/text/api_docs/python/text/WordpieceTokenizer): Tokenizes a tensor of UTF-8 string tokens into subword pieces.

## Functions

[`boise_tags_to_offsets(...)`](https://www.tensorflow.org/text/api_docs/python/text/boise_tags_to_offsets): Converts the token offsets and BOISE tags into span offsets and span type.

[`build_fast_bert_normalizer_model(...)`](https://www.tensorflow.org/text/api_docs/python/text/build_fast_bert_normalizer_model): build_fast_bert_normalizer_model(arg0: bool) -\> bytes

[`build_fast_wordpiece_model(...)`](https://www.tensorflow.org/text/api_docs/python/text/build_fast_wordpiece_model): build_fast_wordpiece_model(arg0: list\[str\], arg1: int, arg2: str, arg3: str, arg4: bool, arg5: bool) -\> bytes

[`case_fold_utf8(...)`](https://www.tensorflow.org/text/api_docs/python/text/case_fold_utf8): Applies case folding to every UTF-8 string in the input.

[`coerce_to_structurally_valid_utf8(...)`](https://www.tensorflow.org/text/api_docs/python/text/coerce_to_structurally_valid_utf8): Coerce UTF-8 input strings to structurally valid UTF-8.

[`combine_segments(...)`](https://www.tensorflow.org/text/api_docs/python/text/combine_segments): Combine one or more input segments for a model's input sequence.

[`concatenate_segments(...)`](https://www.tensorflow.org/text/api_docs/python/text/concatenate_segments): Concatenate input segments for a model's input sequence.

[`find_source_offsets(...)`](https://www.tensorflow.org/text/api_docs/python/text/find_source_offsets): Maps the input post-normalized string offsets to pre-normalized offsets.

[`gather_with_default(...)`](https://www.tensorflow.org/text/api_docs/python/text/gather_with_default): Gather slices with `indices=-1` mapped to `default`.

[`greedy_constrained_sequence(...)`](https://www.tensorflow.org/text/api_docs/python/text/greedy_constrained_sequence): Performs greedy constrained sequence on a batch of examples.

[`mask_language_model(...)`](https://www.tensorflow.org/text/api_docs/python/text/mask_language_model): Applies dynamic language model masking.

[`max_spanning_tree(...)`](https://www.tensorflow.org/text/api_docs/python/text/max_spanning_tree): Finds the maximum directed spanning tree of a digraph.

[`max_spanning_tree_gradient(...)`](https://www.tensorflow.org/text/api_docs/python/text/max_spanning_tree_gradient): Returns a subgradient of the MaximumSpanningTree op.

[`ngrams(...)`](https://www.tensorflow.org/text/api_docs/python/text/ngrams): Create a tensor of n-grams based on the input data `data`.

[`normalize_utf8(...)`](https://www.tensorflow.org/text/api_docs/python/text/normalize_utf8): Normalizes each UTF-8 string in the input tensor using the specified rule.

[`normalize_utf8_with_offsets_map(...)`](https://www.tensorflow.org/text/api_docs/python/text/normalize_utf8_with_offsets_map): Normalizes each UTF-8 string in the input tensor using the specified rule.

[`offsets_to_boise_tags(...)`](https://www.tensorflow.org/text/api_docs/python/text/offsets_to_boise_tags): Converts the given tokens and spans in offsets format into BOISE tags.

[`pad_along_dimension(...)`](https://www.tensorflow.org/text/api_docs/python/text/pad_along_dimension): Add padding to the beginning and end of data in a specific dimension.

[`pad_model_inputs(...)`](https://www.tensorflow.org/text/api_docs/python/text/pad_model_inputs): Pad model input and generate corresponding input masks.

[`regex_split(...)`](https://www.tensorflow.org/text/api_docs/python/text/regex_split): Split `input` by delimiters that match a regex pattern.

[`regex_split_with_offsets(...)`](https://www.tensorflow.org/text/api_docs/python/text/regex_split_with_offsets): Split `input` by delimiters that match a regex pattern; returns offsets.

[`sentence_fragments(...)`](https://www.tensorflow.org/text/api_docs/python/text/sentence_fragments): Find the sentence fragments in a given text. (deprecated)

[`sliding_window(...)`](https://www.tensorflow.org/text/api_docs/python/text/sliding_window): Builds a sliding window for `data` with a specified width.

[`span_alignment(...)`](https://www.tensorflow.org/text/api_docs/python/text/span_alignment): Return an alignment from a set of source spans to a set of target spans.

[`span_overlaps(...)`](https://www.tensorflow.org/text/api_docs/python/text/span_overlaps): Returns a boolean tensor indicating which source and target spans overlap.

[`utf8_binarize(...)`](https://www.tensorflow.org/text/api_docs/python/text/utf8_binarize): Decode UTF8 tokens into code points and return their bits.

[`viterbi_constrained_sequence(...)`](https://www.tensorflow.org/text/api_docs/python/text/viterbi_constrained_sequence): Performs greedy constrained sequence on a batch of examples.

[`wordshape(...)`](https://www.tensorflow.org/text/api_docs/python/text/wordshape): Determine wordshape features for each input string.

<br />

<br />

<br />

| ## Other Members ||
|---|---|
| **version** | `'2.21.1'` |

<br />