chromium/third_party/mediapipe/src/mediapipe/tasks/cc/text/tokenizers/regex_tokenizer.cc

/* Copyright 2022 The MediaPipe Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#include "mediapipe/tasks/cc/text/tokenizers/regex_tokenizer.h"

#include <iostream>

#include "absl/strings/substitute.h"
#include "mediapipe/tasks/cc/text/utils/vocab_utils.h"

namespace mediapipe {
namespace tasks {
namespace text {
namespace tokenizers {

namespace {

LoadVocabAndIndexFromBuffer;
LoadVocabAndIndexFromFile;

constexpr char kStart[] =;
constexpr char kPad[] =;
constexpr char kUnknown[] =;

void buildIndexTokenMap(
    const absl::node_hash_map<std::string, int>& token_index_map,
    absl::node_hash_map<int, absl::string_view>* index_token_map) {}

}  // namespace

// RE2::FindAndConsume requires the delim_re_ to have a matching group in order
// to capture the matched delimiter length. Surround the regex with a
// parenthesis to create a matching group, it's fine if the regex is already
// surrounded by parenthesis.
RegexTokenizer::RegexTokenizer(const std::string& regex_pattern,
                               const std::string& path_to_vocab)
    :{}

RegexTokenizer::RegexTokenizer(const std::string& regex_pattern,
                               const char* vocab_buffer_data,
                               size_t vocab_buffer_size)
    :{}

TokenizerResult RegexTokenizer::Tokenize(const std::string& input) {}

bool RegexTokenizer::LookupId(absl::string_view key, int* result) const {}

bool RegexTokenizer::LookupWord(int vocab_id, absl::string_view* result) const {}

bool RegexTokenizer::GetStartToken(int* start_token) {}

bool RegexTokenizer::GetPadToken(int* pad_token) {}

bool RegexTokenizer::GetUnknownToken(int* unknown_token) {}

}  // namespace tokenizers
}  // namespace text
}  // namespace tasks
}  // namespace mediapipe