File: regex.h

package info (click to toggle)
pytorch-text 0.14.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 11,560 kB
  • sloc: python: 14,197; cpp: 2,404; sh: 214; makefile: 20
file content (25 lines) | stat: -rw-r--r-- 687 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <re2/re2.h>
#include <re2/stringpiece.h>
#include <torch/script.h>
#include <torchtext/csrc/export.h>
#include <string>

namespace torchtext {
struct Regex : torch::CustomClassHolder {
 private:
  RE2* compiled_pattern_;

 public:
  std::string re_str_;

  TORCHTEXT_API Regex(const std::string& re_str);
  TORCHTEXT_API std::string Sub(std::string str, const std::string& repl) const;
  TORCHTEXT_API bool FindAndConsume(re2::StringPiece* input, std::string* text)
      const;
};

TORCHTEXT_API std::string _serialize_regex(
    const c10::intrusive_ptr<Regex>& self);
TORCHTEXT_API c10::intrusive_ptr<Regex> _deserialize_regex(std::string&& state);

} // namespace torchtext