StringNGrams

public final class StringNGrams

Creates ngrams from ragged string data.

This op accepts a ragged tensor with 1 ragged dimension containing only strings and outputs a ragged tensor with 1 ragged dimension containing ngrams of that string, joined along the innermost axis.

Constants

String OP_NAME The name of this op, as known by TensorFlow core engine

Public Methods

static <T extends TNumber > StringNGrams <T>
create ( Scope scope, Operand < TString > data, Operand <T> dataSplits, String separator, List<Long> ngramWidths, String leftPad, String rightPad, Long padWidth, Boolean preserveShortSequences)
Factory method to create a class wrapping a new StringNGrams operation.
Output < TString >
ngrams ()
The values tensor of the output ngrams ragged tensor.
Output <T>
ngramsSplits ()
The splits tensor of the output ngrams ragged tensor.

Inherited Methods

Constants

public static final String OP_NAME

The name of this op, as known by TensorFlow core engine

Constant Value: "StringNGrams"

Public Methods

public static StringNGrams <T> create ( Scope scope, Operand < TString > data, Operand <T> dataSplits, String separator, List<Long> ngramWidths, String leftPad, String rightPad, Long padWidth, Boolean preserveShortSequences)

Factory method to create a class wrapping a new StringNGrams operation.

Parameters
scope current scope
data The values tensor of the ragged string tensor to make ngrams out of. Must be a 1D string tensor.
dataSplits The splits tensor of the ragged string tensor to make ngrams out of.
separator The string to append between elements of the token. Use "" for no separator.
ngramWidths The sizes of the ngrams to create.
leftPad The string to use to pad the left side of the ngram sequence. Only used if pad_width != 0.
rightPad The string to use to pad the right side of the ngram sequence. Only used if pad_width != 0.
padWidth The number of padding elements to add to each side of each sequence. Note that padding will never be greater than 'ngram_widths'-1 regardless of this value. If `pad_width=-1`, then add `max(ngram_widths)-1` elements.
Returns
  • a new instance of StringNGrams

public Output < TString > ngrams ()

The values tensor of the output ngrams ragged tensor.

public Output <T> ngramsSplits ()

The splits tensor of the output ngrams ragged tensor.