!13459 Add example for ngram

From: @ezphlow
Reviewed-by: @heleiwang,@liucunwei
Signed-off-by: @liucunwei
This commit is contained in:
mindspore-ci-bot 2021-03-17 14:11:31 +08:00 committed by Gitee
commit d7e7df3a68
4 changed files with 9 additions and 3 deletions

View File

@ -299,7 +299,11 @@ class Ngram(TextTensorOperation):
(default=None, which will use whitespace as separator).
Examples:
>>> ngram_op = text.Ngram(3, separator="")
>>> ngram_op = text.Ngram(3, separator="-")
>>> output = ngram_op(["WildRose Country", "Canada's Ocean Playground", "Land of Living Skies"])
>>> # output
>>> # ["WildRose Country-Canada's Ocean Playground-Land of Living Skies"]
>>> # same ngram_op called through map
>>> text_file_dataset = text_file_dataset.map(operations=ngram_op)
"""

View File

@ -172,7 +172,7 @@ class Slice(cde.SliceOp):
2. :py:obj:`list(int)`: Slice these indices along the first dimension. Negative indices are supported.
3. :py:obj:`slice`: Slice the generated indices from the slice object along the first dimension.
Similar to start:stop:step.
4. :py:obj:`None`: Slice the whole dimension. Similar to :py:obj:`:` in Python indexing.
4. :py:obj:`None`: Slice the whole dimension. Similar to :py:obj:`[:]' in Python indexing.
5. :py:obj:`Ellipsis`: Slice the whole dimension, same result with `None`.
Examples:

View File

@ -1118,6 +1118,8 @@ class RandomRotation(ImageTensorOperation):
degrees = degrees % 360
if isinstance(degrees, (list, tuple)):
degrees = [degrees[0] % 360, degrees[1] % 360]
if degrees[0] > degrees[1]:
degrees[1] += 360
self.degrees = degrees
self.resample = resample

View File

@ -20,8 +20,8 @@
#include "include/api/status.h"
#include "include/api/types.h"
#include "minddata/dataset/core/tensor_shape.h"
#include "minddata/dataset/core/type_id.h"
#include "minddata/dataset/core/de_tensor.h"
#include "minddata/dataset/core/type_id.h"
#include "utils/log_adapter.h"
using mindspore::Status;