Skip to content

SentencePiece 0.1.97 changed API to take std::vector<string_view> "everywhere", breaking SetVocabulary here #323

Description

@Micket

here

void SentencePiece::set_vocabulary(const std::vector<std::string>& vocabulary,
const Tokenizer::Options* options)
{
if (options && (options->joiner_annotate || options->spacer_new))
throw std::invalid_argument("SentencePiece vocabulary restriction requires the tokenization "
"to use \"spacer_annotate\" (same as spm_encode)");
auto status = _processor->SetVocabulary(vocabulary);

either a quick conversion

    auto status = _processor->SetVocabulary(ToPieceArray(vocabulary));

is needed or possible the string_view should switch should be propagated up the abstractions.

ToPieceArray was added in the same release that made this switch to views.
google/sentencepiece@631420b#diff-77e6a3b3bfda73d84fe1fef8205f2a2ec1d46b8f232100041f7135505f8adcefR52

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions