Class RegexReplace
Defined in File text.h
Inheritance Relationships
Base Type
public mindspore::dataset::TensorTransform
(Class TensorTransform)
Class Documentation
-
class RegexReplace : public mindspore::dataset::TensorTransform
Replace a UTF-8 string tensor with ‘replace’ according to regular expression ‘pattern’.
Public Functions
-
inline RegexReplace(const std::string &pattern, const std::string &replace, bool replace_all = true)
Constructor.
- Parameters
pattern – [in] The regex expression patterns.
replace – [in] The string to replace the matched element.
replace_all – [in] Confirm whether to replace all. If false, only replace the first matched element; if true, replace all matched elements (default=true).
Example/* Define operations */ auto regex_op = text::RegexReplace("\\s+", "_", true); /* dataset is an instance of Dataset object */ dataset = dataset->Map({regex_op}, // operations {"text"}); // input columns
-
RegexReplace(const std::vector<char> &pattern, const std::vector<char> &replace, bool replace_all)
Constructor.
- Parameters
pattern – [in] The regex expression patterns. Type should be char of vector.
replace – [in] The string to replace the matched element.
replace_all – [in] Confirm whether to replace all. If false, only replace the first matched element; if true, replace all matched elements (default=true).
-
~RegexReplace() = default
Destructor.
-
inline RegexReplace(const std::string &pattern, const std::string &replace, bool replace_all = true)