def from_json(cls, json_str):
        """Deserialize BERTVocab object from json string.

        Parameters
        ----------
        json_str : str
            Serialized json string of a BERTVocab object.

        Returns
        -------
        BERTVocab
        """
        vocab_dict = json.loads(json_str)

        unknown_token = vocab_dict.get('unknown_token')
        bert_vocab = cls(unknown_token=unknown_token)
        bert_vocab._idx_to_token = vocab_dict.get('idx_to_token')
        bert_vocab._token_to_idx = vocab_dict.get('token_to_idx')
        if unknown_token:
            bert_vocab._token_to_idx = DefaultLookupDict(bert_vocab._token_to_idx[unknown_token],
                                                         bert_vocab._token_to_idx)
        bert_vocab._reserved_tokens = vocab_dict.get('reserved_tokens')
        bert_vocab._padding_token = vocab_dict.get('padding_token')
        bert_vocab._bos_token = vocab_dict.get('bos_token')
        bert_vocab._eos_token = vocab_dict.get('eos_token')
        bert_vocab._mask_token = vocab_dict.get('mask_token')
        bert_vocab._sep_token = vocab_dict.get('sep_token')
        bert_vocab._cls_token = vocab_dict.get('cls_token')

        return bert_vocab
def from_json ( cls , json_str ) : vocab_dict = json . loads ( json_str ) unknown_token = vocab_dict . get ( 'unknown_token' ) bert_vocab = cls ( unknown_token = unknown_token ) bert_vocab . _idx_to_token = vocab_dict . get ( 'idx_to_token' ) bert_vocab . _token_to_idx = vocab_dict . get ( 'token_to_idx' ) if unknown_token : bert_vocab . _token_to_idx = DefaultLookupDict ( bert_vocab . _token_to_idx [ unknown_token ] , bert_vocab . _token_to_idx ) bert_vocab . _reserved_tokens = vocab_dict . get ( 'reserved_tokens' ) bert_vocab . _padding_token = vocab_dict . get ( 'padding_token' ) bert_vocab . _bos_token = vocab_dict . get ( 'bos_token' ) bert_vocab . _eos_token = vocab_dict . get ( 'eos_token' ) bert_vocab . _mask_token = vocab_dict . get ( 'mask_token' ) bert_vocab . _sep_token = vocab_dict . get ( 'sep_token' ) bert_vocab . _cls_token = vocab_dict . get ( 'cls_token' ) return bert_vocab
Deserialize BERTVocab object from json string.

        Parameters
        ----------
        json_str : str
            Serialized json string of a BERTVocab object.

        Returns
        -------
        BERTVocab