make sentencepiece import conditional in bertjapanesetokenizer (#20012)

This commit is contained in:
Ripose 2022-11-02 04:44:37 -07:00 committed by GitHub
parent 8827e1b217
commit 2e3452af0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,12 +21,15 @@ import os
import unicodedata
from typing import Any, Dict, List, Optional, Tuple
import sentencepiece as spm
from ...tokenization_utils import PreTrainedTokenizer, _is_control, _is_punctuation, _is_whitespace
from ...utils import logging
from ...utils import is_sentencepiece_available, logging
if is_sentencepiece_available():
import sentencepiece as spm
else:
spm = None
logger = logging.get_logger(__name__)
VOCAB_FILES_NAMES = {"vocab_file": "vocab.txt", "spm_file": "spiece.model"}