r""" Constructs a BERT tokenizer. Based on WordPiece. This tokenizer inherits from :class:`~transformers.PreTrainedTokenizer` which contains most of the methods. Users should refer to the superclass for more information regarding methods. Args: vocab_file (:obj:`string`):
| 115 | |
| 116 | |
| 117 | class BertTokenizer(PreTrainedTokenizer): |
| 118 | r""" |
| 119 | Constructs a BERT tokenizer. Based on WordPiece. |
| 120 | |
| 121 | This tokenizer inherits from :class:`~transformers.PreTrainedTokenizer` which contains most of the methods. Users |
| 122 | should refer to the superclass for more information regarding methods. |
| 123 | |
| 124 | Args: |
| 125 | vocab_file (:obj:`string`): |
| 126 | File containing the vocabulary. |
| 127 | do_lower_case (:obj:`bool`, `optional`, defaults to :obj:`True`): |
| 128 | Whether to lowercase the input when tokenizing. |
| 129 | do_basic_tokenize (:obj:`bool`, `optional`, defaults to :obj:`True`): |
| 130 | Whether to do basic tokenization before WordPiece. |
| 131 | never_split (:obj:`Iterable`, `optional`, defaults to :obj:`None`): |
| 132 | Collection of tokens which will never be split during tokenization. Only has an effect when |
| 133 | :obj:`do_basic_tokenize=True` |
| 134 | unk_token (:obj:`string`, `optional`, defaults to "[UNK]"): |
| 135 | The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this |
| 136 | token instead. |
| 137 | sep_token (:obj:`string`, `optional`, defaults to "[SEP]"): |
| 138 | The separator token, which is used when building a sequence from multiple sequences, e.g. two sequences |
| 139 | for sequence classification or for a text and a question for question answering. |
| 140 | It is also used as the last token of a sequence built with special tokens. |
| 141 | pad_token (:obj:`string`, `optional`, defaults to "[PAD]"): |
| 142 | The token used for padding, for example when batching sequences of different lengths. |
| 143 | cls_token (:obj:`string`, `optional`, defaults to "[CLS]"): |
| 144 | The classifier token which is used when doing sequence classification (classification of the whole |
| 145 | sequence instead of per-token classification). It is the first token of the sequence when built with |
| 146 | special tokens. |
| 147 | mask_token (:obj:`string`, `optional`, defaults to "[MASK]"): |
| 148 | The token used for masking values. This is the token used when training this model with masked language |
| 149 | modeling. This is the token which the model will try to predict. |
| 150 | tokenize_chinese_chars (:obj:`bool`, `optional`, defaults to :obj:`True`): |
| 151 | Whether to tokenize Chinese characters. |
| 152 | This should likely be deactivated for Japanese: |
| 153 | see: https://github.com/huggingface/transformers/issues/328 |
| 154 | """ |
| 155 | |
| 156 | vocab_files_names = VOCAB_FILES_NAMES |
| 157 | pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP |
| 158 | pretrained_init_configuration = PRETRAINED_INIT_CONFIGURATION |
| 159 | max_model_input_sizes = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES |
| 160 | |
| 161 | def __init__( |
| 162 | self, |
| 163 | vocab_file, |
| 164 | do_lower_case=True, |
| 165 | do_basic_tokenize=True, |
| 166 | never_split=None, |
| 167 | unk_token="[UNK]", |
| 168 | sep_token="[SEP]", |
| 169 | pad_token="[PAD]", |
| 170 | cls_token="[CLS]", |
| 171 | mask_token="[MASK]", |
| 172 | tokenize_chinese_chars=True, |
| 173 | **kwargs |
| 174 | ): |
nothing calls this directly
no outgoing calls
no test coverage detected