# tensorflow::ops::StringNGrams Class Reference

# 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.


Args:

- scope: A [Scope](https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_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.

<br />


Returns:

- `
  https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output
  ` ngrams: The values tensor of the output ngrams ragged tensor.
- `
  https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output
  ` ngrams_splits: The splits tensor of the output ngrams ragged tensor.

<br />

| ### Constructors and Destructors ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/string-n-grams#classtensorflow_1_1ops_1_1_string_n_grams_1a52a1f08705af6ba58d3607b809b3f835 (const :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input data, :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_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 ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/string-n-grams#classtensorflow_1_1ops_1_1_string_n_grams_1a447bd501492adc42e453473dd818baf0 ` | ` :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output ` |
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/string-n-grams#classtensorflow_1_1ops_1_1_string_n_grams_1af326c6b4d4d0f53e7b7360546c807526 ` | ` :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output ` |
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/string-n-grams#classtensorflow_1_1ops_1_1_string_n_grams_1a96bbeebe04843441f8b36c587ed4f1c9 ` | ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_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
)
```