Missed TensorFlow World? Check out the recap. Learn more

tensorflow::ops::StringNGrams

#include <string_ops.h>

Creates ngrams from ragged string data.

Summary

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.

Arguments:

  • scope: A Scope object
  • data: The values tensor of the ragged string tensor to make ngrams out of. Must be a 1D string tensor.
  • data_splits: 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.
  • ngram_widths: The sizes of the ngrams to create.
  • left_pad: The string to use to pad the left side of the ngram sequence. Only used if pad_width != 0.
  • right_pad: The string to use to pad the right side of the ngram sequence. Only used if pad_width != 0.
  • pad_width: 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:

  • Output ngrams: The values tensor of the output ngrams ragged tensor.
  • Output ngrams_splits: The splits tensor of the output ngrams ragged tensor.

Constructors and Destructors

StringNGrams(const ::tensorflow::Scope & scope, ::tensorflow::Input data, ::tensorflow::Input data_splits, StringPiece separator, const gtl::ArraySlice< int > & ngram_widths, StringPiece left_pad, StringPiece right_pad, int64 pad_width, bool preserve_short_sequences)

Public attributes

ngrams
ngrams_splits
operation

Public attributes

ngrams

::tensorflow::Output ngrams

ngrams_splits

::tensorflow::Output ngrams_splits

operation

Operation operation

Public functions

StringNGrams

 StringNGrams(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input data,
  ::tensorflow::Input data_splits,
  StringPiece separator,
  const gtl::ArraySlice< int > & ngram_widths,
  StringPiece left_pad,
  StringPiece right_pad,
  int64 pad_width,
  bool preserve_short_sequences
)