From a7da38feeb476c6206c5f723ced3624bde883e16 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 16 Mar 2021 22:56:46 -0400 Subject: [PATCH] Added example for ngram --- mindspore/dataset/text/transforms.py | 6 +++++- mindspore/dataset/transforms/c_transforms.py | 2 +- mindspore/dataset/vision/c_transforms.py | 2 ++ tests/ut/cpp/dataset/common/common.h | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mindspore/dataset/text/transforms.py b/mindspore/dataset/text/transforms.py index 00611e1be38..5e5342a000e 100644 --- a/mindspore/dataset/text/transforms.py +++ b/mindspore/dataset/text/transforms.py @@ -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) """ diff --git a/mindspore/dataset/transforms/c_transforms.py b/mindspore/dataset/transforms/c_transforms.py index 20dd3fa583d..463e1be14b7 100644 --- a/mindspore/dataset/transforms/c_transforms.py +++ b/mindspore/dataset/transforms/c_transforms.py @@ -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: diff --git a/mindspore/dataset/vision/c_transforms.py b/mindspore/dataset/vision/c_transforms.py index 94116280952..4bcb7a68ef9 100644 --- a/mindspore/dataset/vision/c_transforms.py +++ b/mindspore/dataset/vision/c_transforms.py @@ -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 diff --git a/tests/ut/cpp/dataset/common/common.h b/tests/ut/cpp/dataset/common/common.h index 22e8bf3e730..800c932a764 100644 --- a/tests/ut/cpp/dataset/common/common.h +++ b/tests/ut/cpp/dataset/common/common.h @@ -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;