MCPcopy Create free account
hub / github.com/SooLab/CGFormer / load_vocab

Function load_vocab

bert/tokenization_bert.py:97–105  ·  view source on GitHub ↗

Loads a vocabulary file into a dictionary.

(vocab_file)

Source from the content-addressed store, hash-verified

95
96
97def load_vocab(vocab_file):
98 """Loads a vocabulary file into a dictionary."""
99 vocab = collections.OrderedDict()
100 with open(vocab_file, "r", encoding="utf-8") as reader:
101 tokens = reader.readlines()
102 for index, token in enumerate(tokens):
103 token = token.rstrip("\n")
104 vocab[token] = index
105 return vocab
106
107
108def whitespace_tokenize(text):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected