Browse Source

Added example for ngram

tags/v1.2.0-rc1
Eric 4 years ago
parent
commit
a7da38feeb
4 changed files with 9 additions and 3 deletions
  1. +5
    -1
      mindspore/dataset/text/transforms.py
  2. +1
    -1
      mindspore/dataset/transforms/c_transforms.py
  3. +2
    -0
      mindspore/dataset/vision/c_transforms.py
  4. +1
    -1
      tests/ut/cpp/dataset/common/common.h

+ 5
- 1
mindspore/dataset/text/transforms.py 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)
"""



+ 1
- 1
mindspore/dataset/transforms/c_transforms.py 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:


+ 2
- 0
mindspore/dataset/vision/c_transforms.py 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


+ 1
- 1
tests/ut/cpp/dataset/common/common.h 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;


Loading…
Cancel
Save